]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
lua: Prevent from loading if it's already loaded
authorculb <redacted>
Mon, 27 Feb 2017 17:14:36 +0000 (12:14 -0500)
committerPatrick Griffis <redacted>
Fri, 28 Apr 2017 11:50:43 +0000 (07:50 -0400)
Closes #1958

plugins/lua/lua.c

index 0dc7aeda7306e2eba44014e0d67dc52184df023b..d284d01a31bb92847639b40c193f95247ac975bf 100644 (file)
@@ -1685,8 +1685,17 @@ static int command_lua(char *word[], char *word_eol[], void *userdata)
        return HEXCHAT_EAT_ALL;
 }
 
+/* Reinitialization safegaurd */
+static int initialized = 0;
+
 G_MODULE_EXPORT int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **name, char **description, char **version, char *arg)
 {
+       if(initialized != 0)
+       {
+               hexchat_print(plugin_handle, "Lua interface already loaded\n");
+               return 0;
+       }
+
        if (g_str_has_prefix(LUA_VERSION, "Lua "))
        {
                strcat(plugin_version, "/");
@@ -1698,6 +1707,7 @@ G_MODULE_EXPORT int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **na
        *version = plugin_version;
 
        ph = plugin_handle;
+       initialized = 1;
 
        hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, command_console_exec, NULL, NULL);
        hexchat_hook_command(ph, "LOAD", HEXCHAT_PRI_NORM, command_load, NULL, NULL);