mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: reset filter and sort when /list buffer is closed (issue #1972)
This commit is contained in:
@@ -248,17 +248,8 @@ irc_buffer_close_cb (const void *pointer, void *data,
|
||||
}
|
||||
else if (ptr_server && (ptr_server->list->buffer == buffer))
|
||||
{
|
||||
irc_list_free_data (ptr_server);
|
||||
ptr_server->list->buffer = NULL;
|
||||
if (ptr_server->list->channels)
|
||||
{
|
||||
weechat_arraylist_free (ptr_server->list->channels);
|
||||
ptr_server->list->channels = NULL;
|
||||
}
|
||||
if (ptr_server->list->filter_channels)
|
||||
{
|
||||
weechat_arraylist_free (ptr_server->list->filter_channels);
|
||||
ptr_server->list->filter_channels = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-10
@@ -1096,6 +1096,46 @@ irc_list_alloc ()
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees data in a list structure.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_list_free_data (struct t_irc_server *server)
|
||||
{
|
||||
if (!server || !server->list)
|
||||
return;
|
||||
|
||||
if (server->list->channels)
|
||||
{
|
||||
weechat_arraylist_free (server->list->channels);
|
||||
server->list->channels = NULL;
|
||||
}
|
||||
if (server->list->filter_channels)
|
||||
{
|
||||
weechat_arraylist_free (server->list->filter_channels);
|
||||
server->list->filter_channels = NULL;
|
||||
}
|
||||
server->list->name_max_length = 0;
|
||||
if (server->list->filter)
|
||||
{
|
||||
free (server->list->filter);
|
||||
server->list->filter = NULL;
|
||||
}
|
||||
if (server->list->sort)
|
||||
{
|
||||
free (server->list->sort);
|
||||
server->list->sort = NULL;
|
||||
}
|
||||
if (server->list->sort_fields)
|
||||
{
|
||||
weechat_string_free_split (server->list->sort_fields);
|
||||
server->list->sort_fields = NULL;
|
||||
}
|
||||
server->list->sort_fields_count = 0;
|
||||
server->list->selected_line = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees a list structure in a server.
|
||||
*/
|
||||
@@ -1108,16 +1148,8 @@ irc_list_free (struct t_irc_server *server)
|
||||
|
||||
if (server->list->buffer)
|
||||
weechat_buffer_close (server->list->buffer);
|
||||
if (server->list->channels)
|
||||
weechat_arraylist_free (server->list->channels);
|
||||
if (server->list->filter_channels)
|
||||
weechat_arraylist_free (server->list->filter_channels);
|
||||
if (server->list->filter)
|
||||
free (server->list->filter);
|
||||
if (server->list->sort)
|
||||
free (server->list->sort);
|
||||
if (server->list->sort_fields)
|
||||
weechat_string_free_split (server->list->sort_fields);
|
||||
|
||||
irc_list_free_data (server);
|
||||
|
||||
free (server->list);
|
||||
server->list = NULL;
|
||||
|
||||
@@ -69,6 +69,7 @@ extern int irc_list_hsignal_redirect_list_cb (const void *pointer,
|
||||
struct t_hashtable *hashtable);
|
||||
extern void irc_list_reset (struct t_irc_server *server);
|
||||
extern struct t_irc_list *irc_list_alloc ();
|
||||
extern void irc_list_free_data (struct t_irc_server *server);
|
||||
extern void irc_list_free (struct t_irc_server *server);
|
||||
extern struct t_hdata *irc_list_hdata_list_channel_cb (const void *pointer,
|
||||
void *data,
|
||||
|
||||
@@ -284,6 +284,16 @@ TEST(IrcList, IrcListAlloc)
|
||||
LONGS_EQUAL(0, list->selected_line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_list_free_data
|
||||
*/
|
||||
|
||||
TEST(IrcList, IrcListFreeData)
|
||||
{
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* irc_list_free
|
||||
|
||||
Reference in New Issue
Block a user