summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/ruby
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-03-24 00:04:00 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-03-24 00:04:00 +0100
commitb491cc34792dedd95457497fa2dec2d890ff3a4c (patch)
tree1dbd7c146352ff19e2d357d80cde9c2bf4960b46 /src/plugins/scripts/ruby
parentf1a946054e86a954f1d7b3f9230898182e4716b1 (diff)
downloadweechat-b491cc34792dedd95457497fa2dec2d890ff3a4c.zip
Fix bug with callbacks when loading a script already loaded
Diffstat (limited to 'src/plugins/scripts/ruby')
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c2
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.c5
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.h1
3 files changed, 7 insertions, 1 deletions
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,