From b491cc34792dedd95457497fa2dec2d890ff3a4c Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 24 Mar 2010 00:04:00 +0100 Subject: Fix bug with callbacks when loading a script already loaded --- src/plugins/scripts/ruby/weechat-ruby-api.c | 2 ++ src/plugins/scripts/ruby/weechat-ruby.c | 5 ++++- src/plugins/scripts/ruby/weechat-ruby.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/plugins/scripts/ruby') 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, -- cgit v1.2.3