diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-24 00:04:00 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-24 00:04:00 +0100 |
commit | b491cc34792dedd95457497fa2dec2d890ff3a4c (patch) | |
tree | 1dbd7c146352ff19e2d357d80cde9c2bf4960b46 /src | |
parent | f1a946054e86a954f1d7b3f9230898182e4716b1 (diff) | |
download | weechat-b491cc34792dedd95457497fa2dec2d890ff3a4c.zip |
Fix bug with callbacks when loading a script already loaded
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.c | 5 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 8 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 2 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 5 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl.c | 5 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl.h | 1 |
15 files changed, 40 insertions, 12 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index b3aa71cc5..3c124282b 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -70,6 +70,7 @@ weechat_lua_api_register (lua_State *L) (void) L; lua_current_script = NULL; + lua_registered_script = NULL; name = NULL; author = NULL; @@ -119,6 +120,7 @@ weechat_lua_api_register (lua_State *L) charset); if (lua_current_script) { + lua_registered_script = lua_current_script; if ((weechat_lua_plugin->debug >= 1) || !lua_quiet) { weechat_printf (NULL, diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 1f69f36b7..5759f97e2 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -45,6 +45,7 @@ int lua_quiet = 0; struct t_plugin_script *lua_scripts = NULL; struct t_plugin_script *last_lua_script = NULL; struct t_plugin_script *lua_current_script = NULL; +struct t_plugin_script *lua_registered_script = NULL; const char *lua_current_script_filename = NULL; lua_State *lua_current_interpreter = NULL; @@ -192,6 +193,7 @@ weechat_lua_load (const char *filename) } lua_current_script = NULL; + lua_registered_script = NULL; lua_current_interpreter = lua_open (); @@ -266,7 +268,7 @@ weechat_lua_load (const char *filename) } fclose (fp); - if (lua_current_script == NULL) + if (!lua_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " @@ -275,6 +277,7 @@ weechat_lua_load (const char *filename) lua_close (lua_current_interpreter); return 0; } + lua_current_script = lua_registered_script; lua_current_script->interpreter = (lua_State *) lua_current_interpreter; diff --git a/src/plugins/scripts/lua/weechat-lua.h b/src/plugins/scripts/lua/weechat-lua.h index 52c7973ea..d22cf47b2 100644 --- a/src/plugins/scripts/lua/weechat-lua.h +++ b/src/plugins/scripts/lua/weechat-lua.h @@ -31,6 +31,7 @@ extern int lua_quiet; extern struct t_plugin_script *lua_scripts; extern struct t_plugin_script *last_lua_script; extern struct t_plugin_script *lua_current_script; +extern struct t_plugin_script *lua_registered_script; extern const char *lua_current_script_filename; extern lua_State *lua_current_interpreter; diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 951f77d90..9d48b32c0 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -76,6 +76,7 @@ XS (XS_weechat_api_register) (void) cv; perl_current_script = NULL; + perl_registered_script = NULL; if (items < 7) { @@ -111,6 +112,7 @@ XS (XS_weechat_api_register) description, shutdown_func, charset); if (perl_current_script) { + perl_registered_script = perl_current_script; if ((weechat_perl_plugin->debug >= 1) || !perl_quiet) { weechat_printf (NULL, diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 447d4717e..0b188609c 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -43,6 +43,7 @@ int perl_quiet = 0; struct t_plugin_script *perl_scripts = NULL; struct t_plugin_script *last_perl_script = NULL; struct t_plugin_script *perl_current_script = NULL; +struct t_plugin_script *perl_registered_script = NULL; const char *perl_current_script_filename = NULL; int perl_quit_or_upgrade = 0; @@ -221,8 +222,7 @@ weechat_perl_exec (struct t_plugin_script *script, FREETMPS; LEAVE; - if (old_perl_current_script) - perl_current_script = old_perl_current_script; + perl_current_script = old_perl_current_script; #ifdef MULTIPLICITY PERL_SET_CONTEXT (old_context); #else @@ -286,6 +286,7 @@ weechat_perl_load (const char *filename) } perl_current_script = NULL; + perl_registered_script = NULL; #ifdef MULTIPLICITY perl_current_interpreter = perl_alloc(); @@ -386,8 +387,8 @@ weechat_perl_load (const char *filename) } free (eval); - - if (!perl_current_script) + + if (!perl_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " @@ -399,7 +400,8 @@ weechat_perl_load (const char *filename) #endif return 0; } - + perl_current_script = perl_registered_script; + #ifdef MULTIPLICITY perl_current_script->interpreter = (PerlInterpreter *)perl_current_interpreter; #else diff --git a/src/plugins/scripts/perl/weechat-perl.h b/src/plugins/scripts/perl/weechat-perl.h index 21dfd4354..0e6b5ccf7 100644 --- a/src/plugins/scripts/perl/weechat-perl.h +++ b/src/plugins/scripts/perl/weechat-perl.h @@ -31,6 +31,7 @@ extern int perl_quiet; extern struct t_plugin_script *perl_scripts; extern struct t_plugin_script *last_perl_script; extern struct t_plugin_script *perl_current_script; +extern struct t_plugin_script *perl_registered_script; extern const char *perl_current_script_filename; extern void *weechat_perl_exec (struct t_plugin_script *script, diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 18edfb334..8c98a99b4 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -66,6 +66,7 @@ weechat_python_api_register (PyObject *self, PyObject *args) (void) self; python_current_script = NULL; + python_registered_script = NULL; name = NULL; author = NULL; @@ -102,6 +103,7 @@ weechat_python_api_register (PyObject *self, PyObject *args) description, shutdown_func, charset); if (python_current_script) { + python_registered_script = python_current_script; if ((weechat_python_plugin->debug >= 1) || !python_quiet) { weechat_printf (NULL, diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 55e1be01e..e16618612 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -41,6 +41,7 @@ int python_quiet; struct t_plugin_script *python_scripts = NULL; struct t_plugin_script *last_python_script = NULL; struct t_plugin_script *python_current_script = NULL; +struct t_plugin_script *python_registered_script = NULL; const char *python_current_script_filename = NULL; PyThreadState *python_mainThreadState = NULL; @@ -228,8 +229,7 @@ weechat_python_exec (struct t_plugin_script *script, /* PyEval_ReleaseThread (python_current_script->interpreter); */ - if (old_python_current_script) - python_current_script = old_python_current_script; + python_current_script = old_python_current_script; if (old_interpreter) PyThreadState_Swap (old_interpreter); @@ -335,6 +335,7 @@ weechat_python_load (const char *filename) } python_current_script = NULL; + python_registered_script = NULL; /* PyEval_AcquireLock (); */ python_current_interpreter = Py_NewInterpreter (); @@ -492,7 +493,7 @@ weechat_python_load (const char *filename) fclose (fp); - if (python_current_script == NULL) + if (!python_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " @@ -506,6 +507,7 @@ weechat_python_load (const char *filename) return 0; } + python_current_script = python_registered_script; python_current_script->interpreter = (PyThreadState *) python_current_interpreter; /* PyEval_ReleaseThread (python_current_script->interpreter); */ diff --git a/src/plugins/scripts/python/weechat-python.h b/src/plugins/scripts/python/weechat-python.h index 8c460b79e..421f73b6b 100644 --- a/src/plugins/scripts/python/weechat-python.h +++ b/src/plugins/scripts/python/weechat-python.h @@ -31,6 +31,7 @@ extern int python_quiet; extern struct t_plugin_script *python_scripts; extern struct t_plugin_script *last_python_script; extern struct t_plugin_script *python_current_script; +extern struct t_plugin_script *python_registered_script; extern const char *python_current_script_filename; extern void *weechat_python_exec (struct t_plugin_script *script, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 2b0a99cd0..5ee74aa54 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -65,6 +65,7 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author, (void) class; ruby_current_script = NULL; + ruby_registered_script = NULL; c_name = NULL; c_author = NULL; @@ -120,6 +121,7 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author, if (ruby_current_script) { + ruby_registered_script = ruby_current_script; if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet) { weechat_printf (NULL, diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 9355dc8e8..eb40a942a 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -64,6 +64,7 @@ int ruby_quiet = 0; struct t_plugin_script *ruby_scripts = NULL; struct t_plugin_script *last_ruby_script = NULL; struct t_plugin_script *ruby_current_script = NULL; +struct t_plugin_script *ruby_registered_script = NULL; const char *ruby_current_script_filename = NULL; /* @@ -476,6 +477,7 @@ weechat_ruby_load (const char *filename) } ruby_current_script = NULL; + ruby_registered_script = NULL; snprintf (modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num); ruby_num++; @@ -553,7 +555,7 @@ weechat_ruby_load (const char *filename) return 0; } - if (ruby_current_script == NULL) + if (!ruby_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " @@ -561,6 +563,7 @@ weechat_ruby_load (const char *filename) weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename); return 0; } + ruby_current_script = ruby_registered_script; ruby_current_script->interpreter = (VALUE *) curModule; rb_gc_register_address (ruby_current_script->interpreter); diff --git a/src/plugins/scripts/ruby/weechat-ruby.h b/src/plugins/scripts/ruby/weechat-ruby.h index 5c1d33a60..89cfad2c3 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.h +++ b/src/plugins/scripts/ruby/weechat-ruby.h @@ -31,6 +31,7 @@ extern int ruby_quiet; extern struct t_plugin_script *ruby_scripts; extern struct t_plugin_script *last_ruby_script; extern struct t_plugin_script *ruby_current_script; +extern struct t_plugin_script *ruby_registered_script; extern const char *ruby_current_script_filename; extern void *weechat_ruby_exec (struct t_plugin_script *script, diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index b9800608e..a9d84a962 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -170,6 +170,7 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, (void) clientData; tcl_current_script = NULL; + tcl_registered_script = NULL; if (objc < 8) { @@ -205,6 +206,7 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, description, shutdown_func, charset); if (tcl_current_script) { + tcl_registered_script = tcl_current_script; if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet) { weechat_printf (NULL, @@ -218,7 +220,7 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, { TCL_RETURN_ERROR; } - + TCL_RETURN_OK; } diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/scripts/tcl/weechat-tcl.c index cd2216b68..18d828c15 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/scripts/tcl/weechat-tcl.c @@ -46,6 +46,7 @@ int tcl_quiet = 0; struct t_plugin_script *tcl_scripts = NULL; struct t_plugin_script *last_tcl_script = NULL; struct t_plugin_script *tcl_current_script = NULL; +struct t_plugin_script *tcl_registered_script = NULL; const char *tcl_current_script_filename = NULL; /* @@ -181,6 +182,7 @@ weechat_tcl_load (const char *filename) } tcl_current_script = NULL; + tcl_registered_script = NULL; if (!(interp = Tcl_CreateInterp ())) { weechat_printf (NULL, @@ -204,7 +206,7 @@ weechat_tcl_load (const char *filename) /* return 0; */ } - if (!tcl_current_script) + if (!tcl_registered_script) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"register\" not " @@ -213,6 +215,7 @@ weechat_tcl_load (const char *filename) Tcl_DeleteInterp (interp); return 0; } + tcl_current_script = tcl_registered_script; return 1; } diff --git a/src/plugins/scripts/tcl/weechat-tcl.h b/src/plugins/scripts/tcl/weechat-tcl.h index d6b9013cf..d680fe8da 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.h +++ b/src/plugins/scripts/tcl/weechat-tcl.h @@ -31,6 +31,7 @@ extern int tcl_quiet; extern struct t_plugin_script *tcl_scripts; extern struct t_plugin_script *last_tcl_script; extern struct t_plugin_script *tcl_current_script; +extern struct t_plugin_script *tcl_registered_script; extern const char *tcl_current_script_filename; extern void *weechat_tcl_exec (struct t_plugin_script *script, |