summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-07-02 12:51:09 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-07-02 12:51:09 +0200
commit093032bc8d63eb26bf50fb916f41d20cb9da1527 (patch)
tree59c2c1f8585430f2f1b30be036fd1f4d29e0d3bf
parent4ce0d2af6d614802722cedcef39bf9d79a3a5fcd (diff)
downloadweechat-093032bc8d63eb26bf50fb916f41d20cb9da1527.zip
fset: always use a timer to refresh buffer when options are changed
-rw-r--r--src/plugins/fset/fset-command.c8
-rw-r--r--src/plugins/fset/fset-config.c1
-rw-r--r--src/plugins/fset/fset-option.c84
-rw-r--r--src/plugins/fset/fset-option.h2
4 files changed, 26 insertions, 69 deletions
diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c
index ee2fef084..2538e5d63 100644
--- a/src/plugins/fset/fset-command.c
+++ b/src/plugins/fset/fset-command.c
@@ -237,7 +237,6 @@ fset_command_fset (const void *pointer, void *data,
{
if (fset_option_count_marked > 0)
{
- fset_option_enable_timer_config_changed ();
num_options = weechat_arraylist_size (fset_options);
for (i = 0; i < num_options; i++)
{
@@ -249,7 +248,6 @@ fset_command_fset (const void *pointer, void *data,
fset_option_toggle_value (ptr_fset_option, ptr_option);
}
}
- fset_option_disable_timer_config_changed ();
}
else
{
@@ -270,7 +268,6 @@ fset_command_fset (const void *pointer, void *data,
if (fset_option_count_marked > 0)
{
- fset_option_enable_timer_config_changed ();
num_options = weechat_arraylist_size (fset_options);
for (i = 0; i < num_options; i++)
{
@@ -282,7 +279,6 @@ fset_command_fset (const void *pointer, void *data,
fset_option_add_value (ptr_fset_option, ptr_option, value);
}
}
- fset_option_disable_timer_config_changed ();
}
else
{
@@ -306,7 +302,6 @@ fset_command_fset (const void *pointer, void *data,
{
if (fset_option_count_marked > 0)
{
- fset_option_enable_timer_config_changed ();
num_options = weechat_arraylist_size (fset_options);
for (i = 0; i < num_options; i++)
{
@@ -318,7 +313,6 @@ fset_command_fset (const void *pointer, void *data,
fset_option_reset_value (ptr_fset_option, ptr_option);
}
}
- fset_option_disable_timer_config_changed ();
}
else
{
@@ -332,7 +326,6 @@ fset_command_fset (const void *pointer, void *data,
{
if (fset_option_count_marked > 0)
{
- fset_option_enable_timer_config_changed ();
num_options = weechat_arraylist_size (fset_options);
for (i = 0; i < num_options; i++)
{
@@ -344,7 +337,6 @@ fset_command_fset (const void *pointer, void *data,
fset_option_unset_value (ptr_fset_option, ptr_option);
}
}
- fset_option_disable_timer_config_changed ();
}
else
{
diff --git a/src/plugins/fset/fset-config.c b/src/plugins/fset/fset-config.c
index 8cc9d1690..f6ed68b44 100644
--- a/src/plugins/fset/fset-config.c
+++ b/src/plugins/fset/fset-config.c
@@ -130,7 +130,6 @@ fset_config_change_show_plugins_desc_cb (const void *pointer, void *data,
if (fset_buffer)
{
- fset_buffer_selected_line = 0;
fset_option_get_options ();
fset_buffer_refresh (1);
}
diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c
index 9b364f2e1..f638052b3 100644
--- a/src/plugins/fset/fset-option.c
+++ b/src/plugins/fset/fset-option.c
@@ -43,7 +43,6 @@ struct t_hashtable *fset_option_filter_hashtable_extra_vars = NULL;
struct t_hashtable *fset_option_filter_hashtable_options = NULL;
/* refresh */
-int fset_option_config_changed_use_timer = 0;
struct t_hashtable *fset_option_timer_options_changed = NULL;
struct t_hook *fset_option_timer_hook = NULL;
@@ -1477,18 +1476,10 @@ fset_option_config_timer_cb (const void *pointer,
(void) data;
(void) remaining_calls;
- if (fset_option_timer_options_changed)
- {
- weechat_hashtable_map (fset_option_timer_options_changed,
- &fset_option_timer_option_changed_cb,
- NULL);
- weechat_hashtable_free (fset_option_timer_options_changed);
- fset_option_timer_options_changed = NULL;
- }
- else
- {
- fset_option_config_changed (NULL);
- }
+ weechat_hashtable_map (fset_option_timer_options_changed,
+ &fset_option_timer_option_changed_cb,
+ NULL);
+ weechat_hashtable_remove_all (fset_option_timer_options_changed);
fset_option_timer_hook = NULL;
@@ -1521,55 +1512,17 @@ fset_option_config_cb (const void *pointer,
if (ptr_info && (strcmp (ptr_info, "1") == 0))
return WEECHAT_RC_OK;
- if (fset_option_config_changed_use_timer)
- {
- if (!fset_option_timer_hook)
- {
- fset_option_timer_hook = weechat_hook_timer (
- 1, 0, 1,
- &fset_option_config_timer_cb, NULL, NULL);
- }
- weechat_hashtable_set (fset_option_timer_options_changed,
- option, NULL);
- }
- else
- {
- fset_option_config_changed (option);
- }
-
- return WEECHAT_RC_OK;
-}
-
-/*
- * Enables a timer when options are changed.
- */
+ weechat_hashtable_set (fset_option_timer_options_changed,
+ option, NULL);
-void
-fset_option_enable_timer_config_changed ()
-{
- if (fset_option_timer_options_changed)
+ if (!fset_option_timer_hook)
{
- weechat_hashtable_remove_all (fset_option_timer_options_changed);
+ fset_option_timer_hook = weechat_hook_timer (
+ 1, 0, 1,
+ &fset_option_config_timer_cb, NULL, NULL);
}
- else
- {
- fset_option_timer_options_changed = weechat_hashtable_new (
- 32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_POINTER,
- NULL, NULL);
- }
- fset_option_config_changed_use_timer = 1;
-}
-
-/*
- * Disables timer when options are changed.
- */
-void
-fset_option_disable_timer_config_changed ()
-{
- fset_option_config_changed_use_timer = 0;
+ return WEECHAT_RC_OK;
}
/*
@@ -1769,6 +1722,21 @@ fset_option_init ()
weechat_hashtable_set (fset_option_filter_hashtable_options,
"type", "condition");
+ fset_option_timer_options_changed = weechat_hashtable_new (
+ 128,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL, NULL);
+ if (!fset_option_timer_options_changed)
+ {
+ weechat_arraylist_free (fset_options);
+ free (fset_option_max_length);
+ weechat_hashtable_free (fset_option_filter_hashtable_pointers);
+ weechat_hashtable_free (fset_option_filter_hashtable_extra_vars);
+ weechat_hashtable_free (fset_option_filter_hashtable_options);
+ return 0;
+ }
+
return 1;
}
diff --git a/src/plugins/fset/fset-option.h b/src/plugins/fset/fset-option.h
index 6ac4f3c40..93159ac9a 100644
--- a/src/plugins/fset/fset-option.h
+++ b/src/plugins/fset/fset-option.h
@@ -120,8 +120,6 @@ extern int fset_option_config_cb (const void *pointer,
void *data,
const char *option,
const char *value);
-extern void fset_option_enable_timer_config_changed ();
-extern void fset_option_disable_timer_config_changed ();
extern struct t_hdata *fset_option_hdata_option_cb (const void *pointer,
void *data,
const char *hdata_name);