summary refs log tree commit diff stats
path: root/plugins/lua
diff options
context:
space:
mode:
authorculb <the01culb@gmail.com>2017-02-27 12:14:36 -0500
committerPatrick Griffis <tingping@tingping.se>2017-04-28 07:50:43 -0400
commit5d72755027ddf4e2e2715ae505c3437f9617a5b4 (patch)
treebab349ccc1bcfc0b4996e6d438fbfecb477ab6a5 /plugins/lua
parent92496b183e48a067e89e4a48944526cf278b852a (diff)
lua: Prevent from loading if it's already loaded
Closes #1958
Diffstat (limited to 'plugins/lua')
-rw-r--r--plugins/lua/lua.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c
index 0dc7aeda..d284d01a 100644
--- a/plugins/lua/lua.c
+++ b/plugins/lua/lua.c
@@ -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);