core: fix crash on buffer close when option weechat.look.hotlist_remove is set to "merged" (closes #199)

(cherry picked from commit c1aa51fa9c9143729455c2fe19b70965abd82375)
This commit is contained in:
Sébastien Helleu 2014-09-24 21:45:01 +02:00
parent 782d812720
commit 53de7764a1
7 changed files with 18 additions and 11 deletions

View File

@ -17,6 +17,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
=== Bugs fixed
* core: fix crash on buffer close when option weechat.look.hotlist_remove is
set to "merged" (closes #199)
* core: fix highlight of IRC action messages when option irc.look.nick_mode is
set to "action" or "both" (closes #206)
* core: fix compilation of plugin API functions (macros) when compiler

View File

@ -1224,7 +1224,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
gui_buffer_compute_num_displayed ();
if (!weechat_upgrading && (old_buffer != buffer))
gui_hotlist_remove_buffer (buffer);
gui_hotlist_remove_buffer (buffer, 0);
gui_bar_window_remove_unused_bars (window);
gui_bar_window_add_missing_bars (window);

View File

@ -1730,7 +1730,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
if (error && !error[0])
{
if (number < 0)
gui_hotlist_remove_buffer (buffer);
gui_hotlist_remove_buffer (buffer, 0);
else
(void) gui_hotlist_add (buffer, number, NULL);
}
@ -2480,7 +2480,7 @@ gui_buffer_clear (struct t_gui_buffer *buffer)
}
}
gui_hotlist_remove_buffer (buffer);
gui_hotlist_remove_buffer (buffer, 0);
gui_buffer_ask_chat_refresh (buffer, 2);
@ -2601,7 +2601,7 @@ gui_buffer_close (struct t_gui_buffer *buffer)
}
}
gui_hotlist_remove_buffer (buffer);
gui_hotlist_remove_buffer (buffer, 1);
if (gui_hotlist_initial_buffer == buffer)
gui_hotlist_initial_buffer = NULL;

View File

@ -487,7 +487,8 @@ gui_hotlist_clear ()
*/
void
gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
gui_hotlist_remove_buffer (struct t_gui_buffer *buffer,
int force_remove_buffer)
{
int hotlist_changed, hotlist_remove, buffer_to_remove;
struct t_gui_hotlist *ptr_hotlist, *next_hotlist;
@ -504,19 +505,22 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
{
next_hotlist = ptr_hotlist->next_hotlist;
buffer_to_remove = 0;
buffer_to_remove = (force_remove_buffer) ?
(ptr_hotlist->buffer == buffer) : 0;
switch (hotlist_remove)
{
case CONFIG_LOOK_HOTLIST_REMOVE_BUFFER:
buffer_to_remove = (ptr_hotlist->buffer == buffer);
buffer_to_remove |= (ptr_hotlist->buffer == buffer);
break;
case CONFIG_LOOK_HOTLIST_REMOVE_MERGED:
buffer_to_remove =
buffer_to_remove |=
((ptr_hotlist->buffer->number == buffer->number)
&& (!ptr_hotlist->buffer->zoomed
|| (ptr_hotlist->buffer->active == 2)));
break;
}
if (buffer_to_remove)
{
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);

View File

@ -59,7 +59,8 @@ extern struct t_gui_hotlist *gui_hotlist_add (struct t_gui_buffer *buffer,
struct timeval *creation_time);
extern void gui_hotlist_resort ();
extern void gui_hotlist_clear ();
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer);
extern void gui_hotlist_remove_buffer (struct t_gui_buffer *buffer,
int force_remove_buffer);
extern struct t_hdata *gui_hotlist_hdata_hotlist_cb (void *data,
const char *hdata_name);
extern int gui_hotlist_add_to_infolist (struct t_infolist *infolist,

View File

@ -1383,7 +1383,7 @@ gui_input_jump_smart (struct t_gui_buffer *buffer)
if (!gui_hotlist_initial_buffer)
gui_hotlist_initial_buffer = window->buffer;
gui_window_switch_to_buffer (window, gui_hotlist->buffer, 1);
gui_hotlist_remove_buffer (window->buffer);
gui_hotlist_remove_buffer (window->buffer, 0);
scroll_to_bottom = 1;
}
else

View File

@ -1673,7 +1673,7 @@ gui_window_search_stop (struct t_gui_window *window)
}
window->scroll->start_line = NULL;
window->scroll->start_line_pos = 0;
gui_hotlist_remove_buffer (window->buffer);
gui_hotlist_remove_buffer (window->buffer, 0);
gui_buffer_ask_chat_refresh (window->buffer, 2);
}