diff --git a/src/perl/common/Irssi.xs b/src/perl/common/Irssi.xs index 53278dcb..67d5e96c 100644 --- a/src/perl/common/Irssi.xs +++ b/src/perl/common/Irssi.xs @@ -1,5 +1,7 @@ #include "module.h" +static int initialized = FALSE; + MODULE = Irssi PACKAGE = Irssi PROTOTYPES: ENABLE @@ -7,12 +9,16 @@ PROTOTYPES: ENABLE void init() CODE: + if (initialized) return; perl_api_version_check("Irssi"); + initialized = TRUE; + perl_settings_init(); void deinit() CODE: + if (!initialized) return; perl_settings_deinit(); BOOT: diff --git a/src/perl/module.h b/src/perl/module.h index f936fb37..bf00817d 100644 --- a/src/perl/module.h +++ b/src/perl/module.h @@ -21,5 +21,5 @@ extern PerlInterpreter *my_perl; /* must be called my_perl or some perl implemen #define MODULE_NAME "perl/core" /* Change this every time when some API changes between irssi's perl module - and irssi's perl libraries. */ -#define IRSSI_PERL_API_VERSION 20011021 + (or irssi itself) and irssi's perl libraries. */ +#define IRSSI_PERL_API_VERSION 20011111 diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index 40041127..29ce0308 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -141,6 +141,9 @@ void perl_scripts_init(void) /* Destroy all perl scripts and deinitialize perl interpreter */ void perl_scripts_deinit(void) { + if (my_perl == NULL) + return; + /* destroy all scripts */ while (perl_scripts != NULL) perl_script_destroy(perl_scripts->data); @@ -417,7 +420,7 @@ static void sig_script_error(PERL_SCRIPT_REC *script, const char *error) } } -static void sig_autorun() +static void sig_autorun(void) { signal_remove("irssi init finished", (SIGNAL_FUNC) sig_autorun); diff --git a/src/perl/perl-core.h b/src/perl/perl-core.h index 206ce818..a883ead0 100644 --- a/src/perl/perl-core.h +++ b/src/perl/perl-core.h @@ -41,14 +41,9 @@ int perl_get_api_version(void); /* Checks that the API version is correct. */ #define perl_api_version_check(library) \ if (perl_get_api_version() != IRSSI_PERL_API_VERSION) { \ - char *str; \ - str = g_strdup_printf("Version of perl module (%d) " \ - "doesn't match the version of " \ - library" library (%d)", \ - perl_get_api_version(), \ - IRSSI_PERL_API_VERSION); \ - signal_emit("gui dialog", 2, "error", str); \ - g_free(str); \ + die("Version of perl module (%d) doesn't match the " \ + "version of "library" library (%d)", \ + perl_get_api_version(), IRSSI_PERL_API_VERSION); \ return; \ } diff --git a/src/perl/textui/TextUI.xs b/src/perl/textui/TextUI.xs index c92da84a..ba08ccdf 100644 --- a/src/perl/textui/TextUI.xs +++ b/src/perl/textui/TextUI.xs @@ -1,5 +1,7 @@ #include "module.h" +static int initialized = FALSE; + static void perl_main_window_fill_hash(HV *hv, MAIN_WINDOW_REC *window) { hv_store(hv, "active", 6, plain_bless(window->active, "Irssi::UI::Window"), 0); @@ -87,8 +89,6 @@ PROTOTYPES: ENABLE void init() -PREINIT: - static int initialized = FALSE; CODE: if (initialized) return; perl_api_version_check("Irssi::TextUI"); @@ -100,6 +100,7 @@ CODE: void deinit() CODE: + if (!initialized) return; perl_statusbar_deinit(); MODULE = Irssi::TextUI PACKAGE = Irssi diff --git a/src/perl/ui/UI.xs b/src/perl/ui/UI.xs index 0f7a39ac..1af7f96f 100644 --- a/src/perl/ui/UI.xs +++ b/src/perl/ui/UI.xs @@ -1,5 +1,7 @@ #include "module.h" +static int initialized = FALSE; + static void perl_process_fill_hash(HV *hv, PROCESS_REC *process) { hv_store(hv, "id", 2, newSViv(process->id), 0); @@ -70,8 +72,6 @@ PROTOTYPES: ENABLE void init() -PREINIT: - static int initialized = FALSE; CODE: if (initialized) return; perl_api_version_check("Irssi::UI"); @@ -83,6 +83,7 @@ CODE: void deinit() CODE: + if (!initialized) return; perl_themes_deinit(); BOOT: