Created
May 11, 2016 22:27
-
-
Save etrunko/a2dafb25c0ca49175c2b57b6f7011de9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From cee57a0dcc598615d4610b495e75f41917cc2311 Mon Sep 17 00:00:00 2001 | |
From: "Eduardo Lima (Etrunko)" <eblima@gmail.com> | |
Date: Wed, 11 May 2016 19:04:40 -0300 | |
Subject: [PATCH] Make closed channels a global variable | |
Signed-off-by: Eduardo Lima (Etrunko) <eblima@gmail.com> | |
--- | |
src/common/hexchat.c | 1 + | |
src/common/hexchatc.h | 1 + | |
src/fe-gtk/maingui.c | 24 +++++++++++++----------- | |
3 files changed, 15 insertions(+), 11 deletions(-) | |
diff --git a/src/common/hexchat.c b/src/common/hexchat.c | |
index 499df8b..be0a543 100644 | |
--- a/src/common/hexchat.c | |
+++ b/src/common/hexchat.c | |
@@ -73,6 +73,7 @@ GSList *ignore_list = 0; | |
GSList *usermenu_list = 0; | |
GSList *urlhandler_list = 0; | |
GSList *tabmenu_list = 0; | |
+GQueue *closedchannels_list = 0; | |
/* | |
* This array contains 5 double linked lists, one for each priority in the | |
diff --git a/src/common/hexchatc.h b/src/common/hexchatc.h | |
index 9d60387..b9e8dfc 100644 | |
--- a/src/common/hexchatc.h | |
+++ b/src/common/hexchatc.h | |
@@ -46,6 +46,7 @@ extern GSList *usermenu_list; | |
extern GSList *urlhandler_list; | |
extern GSList *tabmenu_list; | |
extern GList *sess_list_by_lastact[]; | |
+extern GQueue *closedchannels_list; | |
session * find_channel (server *serv, char *chan); | |
session * find_dialog (server *serv, char *nick); | |
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c | |
index e29dcb1..028c8ba 100644 | |
--- a/src/fe-gtk/maingui.c | |
+++ b/src/fe-gtk/maingui.c | |
@@ -1090,8 +1090,6 @@ typedef struct closed_channel { | |
char key[64]; | |
} closed_channel; | |
-static GQueue closed_channels = G_QUEUE_INIT; | |
- | |
void | |
mg_tab_close (session *sess) | |
{ | |
@@ -1101,12 +1099,8 @@ mg_tab_close (session *sess) | |
if (hexchat_is_quitting) | |
{ | |
- closed_channel *chan; | |
- while (!g_queue_is_empty(&closed_channels)) | |
- { | |
- chan = g_queue_pop_head(&closed_channels); | |
- g_free(chan); | |
- } | |
+ if (closedchannels_list) | |
+ g_queue_free_full(closedchannels_list, g_free); | |
} | |
else if (is_channel (sess->server, sess->channel)) | |
{ | |
@@ -1114,7 +1108,10 @@ mg_tab_close (session *sess) | |
chan->server = sess->server; | |
g_strlcpy(chan->channel, sess->channel, CHANLEN); | |
g_strlcpy(chan->key, sess->channelkey, 64); | |
- g_queue_push_head(&closed_channels, chan); | |
+ | |
+ if (!closedchannels_list) | |
+ closedchannels_list = g_queue_new(); | |
+ g_queue_push_head(closedchannels_list, chan); | |
} | |
if (chan_remove (sess->res->tab, FALSE)) | |
@@ -1150,14 +1147,19 @@ mg_undo_tab_close (session *sess) | |
{ | |
closed_channel *chan; | |
- if (g_queue_is_empty(&closed_channels)) | |
+ if (!closedchannels_list) | |
+ return; | |
+ | |
+ if (g_queue_is_empty(closedchannels_list)) | |
return; | |
- chan = g_queue_pop_head(&closed_channels); | |
+ chan = g_queue_pop_head(closedchannels_list); | |
if (is_server (chan->server)) | |
chan->server->p_join (chan->server, chan->channel, chan->key); | |
g_free(chan); | |
+ if (g_queue_is_empty(closedchannels_list)) | |
+ g_clear_pointer(&closedchannels_list, g_queue_free); | |
} | |
static void | |
-- | |
2.5.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment