1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 16:45:42 +02:00

scripts: fix crash with scripts not auto-loaded having a buffer opened after /upgrade (input/close callbacks for buffer not set properly)

This commit is contained in:
Sebastien Helleu
2011-08-17 12:53:34 +02:00
parent 168b1dd2b0
commit df69add970
8 changed files with 167 additions and 147 deletions
+11 -4
View File
@@ -347,6 +347,16 @@ weechat_lua_load (const char *filename)
lua_current_script->interpreter = (lua_State *) lua_current_interpreter;
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
*/
script_set_buffer_callbacks (weechat_lua_plugin,
lua_scripts,
lua_current_script,
&weechat_lua_api_buffer_input_data_cb,
&weechat_lua_api_buffer_close_cb);
return 1;
}
@@ -724,16 +734,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_init (weechat_lua_plugin,
argc,
argv,
&lua_scripts,
&weechat_lua_command_cb,
&weechat_lua_completion_cb,
&weechat_lua_infolist_cb,
&weechat_lua_signal_debug_dump_cb,
&weechat_lua_signal_buffer_closed_cb,
&weechat_lua_signal_script_action_cb,
&weechat_lua_load_cb,
&weechat_lua_api_buffer_input_data_cb,
&weechat_lua_api_buffer_close_cb);
&weechat_lua_load_cb);
lua_quiet = 0;
script_display_short_list (weechat_lua_plugin,
+12 -5
View File
@@ -521,7 +521,17 @@ weechat_perl_load (const char *filename)
#else
perl_current_script->interpreter = strdup (pkgname);
#endif
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
*/
script_set_buffer_callbacks (weechat_perl_plugin,
perl_scripts,
perl_current_script,
&weechat_perl_api_buffer_input_data_cb,
&weechat_perl_api_buffer_close_cb);
return 1;
}
@@ -966,16 +976,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_init (weechat_perl_plugin,
argc,
argv,
&perl_scripts,
&weechat_perl_command_cb,
&weechat_perl_completion_cb,
&weechat_perl_infolist_cb,
&weechat_perl_signal_debug_dump_cb,
&weechat_perl_signal_buffer_closed_cb,
&weechat_perl_signal_script_action_cb,
&weechat_perl_load_cb,
&weechat_perl_api_buffer_input_data_cb,
&weechat_perl_api_buffer_close_cb);
&weechat_perl_load_cb);
perl_quiet = 0;
script_display_short_list (weechat_perl_plugin,
+11 -4
View File
@@ -609,6 +609,16 @@ weechat_python_load (const char *filename)
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
/* PyEval_ReleaseThread (python_current_script->interpreter); */
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
*/
script_set_buffer_callbacks (weechat_python_plugin,
python_scripts,
python_current_script,
&weechat_python_api_buffer_input_data_cb,
&weechat_python_api_buffer_close_cb);
return 1;
}
@@ -1052,16 +1062,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_init (weechat_python_plugin,
argc,
argv,
&python_scripts,
&weechat_python_command_cb,
&weechat_python_completion_cb,
&weechat_python_infolist_cb,
&weechat_python_signal_debug_dump_cb,
&weechat_python_signal_buffer_closed_cb,
&weechat_python_signal_script_action_cb,
&weechat_python_load_cb,
&weechat_python_api_buffer_input_data_cb,
&weechat_python_api_buffer_close_cb);
&weechat_python_load_cb);
python_quiet = 0;
script_display_short_list (weechat_python_plugin,
+11 -4
View File
@@ -582,6 +582,16 @@ weechat_ruby_load (const char *filename)
ruby_current_script->interpreter = (VALUE *) curModule;
rb_gc_register_address (ruby_current_script->interpreter);
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
*/
script_set_buffer_callbacks (weechat_ruby_plugin,
ruby_scripts,
ruby_current_script,
&weechat_ruby_api_buffer_input_data_cb,
&weechat_ruby_api_buffer_close_cb);
return 1;
}
@@ -1059,16 +1069,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_init (weechat_ruby_plugin,
argc,
argv,
&ruby_scripts,
&weechat_ruby_command_cb,
&weechat_ruby_completion_cb,
&weechat_ruby_infolist_cb,
&weechat_ruby_signal_debug_dump_cb,
&weechat_ruby_signal_buffer_closed_cb,
&weechat_ruby_signal_script_action_cb,
&weechat_ruby_load_cb,
&weechat_ruby_api_buffer_input_data_cb,
&weechat_ruby_api_buffer_close_cb);
&weechat_ruby_load_cb);
ruby_quiet = 0;
script_display_short_list (weechat_ruby_plugin,
File diff suppressed because it is too large Load Diff
+9 -7
View File
@@ -71,7 +71,6 @@ struct t_plugin_script
extern void script_init (struct t_weechat_plugin *weechat_plugin,
int argc,
char *argv[],
struct t_plugin_script **scripts,
int (*callback_command)(void *data,
struct t_gui_buffer *buffer,
int argc, char **argv,
@@ -96,12 +95,7 @@ extern void script_init (struct t_weechat_plugin *weechat_plugin,
const char *signal,
const char *type_data,
void *signal_data),
void (*callback_load_file)(void *data, const char *filename),
int (*callback_buffer_input) (void *data,
struct t_gui_buffer *buffer,
const char *input_data),
int (*callback_buffer_close) (void *data,
struct t_gui_buffer *buffer));
void (*callback_load_file)(void *data, const char *filename));
extern int script_valid (struct t_plugin_script *scripts,
struct t_plugin_script *script);
extern char *script_ptr2str (void *pointer);
@@ -120,6 +114,14 @@ extern struct t_plugin_script *script_add (struct t_weechat_plugin *weechat_plug
const char *author, const char *version,
const char *license, const char *description,
const char *shutdown_func, const char *charset);
extern void script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
struct t_plugin_script *script,
int (*callback_buffer_input) (void *data,
struct t_gui_buffer *buffer,
const char *input_data),
int (*callback_buffer_close) (void *data,
struct t_gui_buffer *buffer));
extern void script_remove_buffer_callbacks (struct t_plugin_script *scripts,
struct t_gui_buffer *buffer);
extern void script_remove (struct t_weechat_plugin *weechat_plugin,
+11 -4
View File
@@ -333,6 +333,16 @@ weechat_tcl_load (const char *filename)
}
tcl_current_script = tcl_registered_script;
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
*/
script_set_buffer_callbacks (weechat_tcl_plugin,
tcl_scripts,
tcl_current_script,
&weechat_tcl_api_buffer_input_data_cb,
&weechat_tcl_api_buffer_close_cb);
return 1;
}
@@ -710,16 +720,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
script_init (weechat_tcl_plugin,
argc,
argv,
&tcl_scripts,
&weechat_tcl_command_cb,
&weechat_tcl_completion_cb,
&weechat_tcl_infolist_cb,
&weechat_tcl_signal_debug_dump_cb,
&weechat_tcl_signal_buffer_closed_cb,
&weechat_tcl_signal_script_action_cb,
&weechat_tcl_load_cb,
&weechat_tcl_api_buffer_input_data_cb,
&weechat_tcl_api_buffer_close_cb);
&weechat_tcl_load_cb);
tcl_quiet = 0;
script_display_short_list (weechat_tcl_plugin,