diff --git a/src/perl/irssi-core.pl b/src/perl/irssi-core.pl index a63a723c..31fbe484 100644 --- a/src/perl/irssi-core.pl +++ b/src/perl/irssi-core.pl @@ -13,13 +13,12 @@ sub is_static { } sub destroy { - my $package = "Irssi::Script::".$_[0]; - delete_package($package); + delete_package($_[0]); } sub eval_data { my ($data, $id) = @_; - destroy($id); + destroy("Irssi::Script::$id"); my $package = "Irssi::Script::$id"; my $eval = qq{package $package; %s sub handler { $data; }}; diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index 29ce0308..e24bff1b 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -144,9 +144,9 @@ void perl_scripts_deinit(void) if (my_perl == NULL) return; - /* destroy all scripts */ + /* unload all scripts */ while (perl_scripts != NULL) - perl_script_destroy(perl_scripts->data); + perl_script_unload(perl_scripts->data); signal_emit("perl scripts deinit", 0); @@ -164,15 +164,6 @@ void perl_scripts_deinit(void) my_perl = NULL; } -/* Unload perl script */ -void perl_script_unload(PERL_SCRIPT_REC *script) -{ - g_return_if_fail(script != NULL); - - perl_script_destroy_package(script); - perl_script_destroy(script); -} - static char *script_file_get_name(const char *path) { char *name, *ret, *p; @@ -300,6 +291,15 @@ PERL_SCRIPT_REC *perl_script_load_data(const char *data) return script_load(name, NULL, data); } +/* Unload perl script */ +void perl_script_unload(PERL_SCRIPT_REC *script) +{ + g_return_if_fail(script != NULL); + + perl_script_destroy_package(script); + perl_script_destroy(script); +} + /* Find loaded script by name */ PERL_SCRIPT_REC *perl_script_find(const char *name) { @@ -415,7 +415,7 @@ static void sig_script_error(PERL_SCRIPT_REC *script, const char *error) } if (script != NULL) { - perl_script_destroy(script); + perl_script_unload(script); signal_stop(); } }