pidgin: 91d99da9: Fix a race related to closing the roomli...
datallah at pidgin.im
datallah at pidgin.im
Mon Jul 28 23:46:24 EDT 2008
-----------------------------------------------------------------
Revision: 91d99da9c9328ef874880c805ed522358fba57ba
Ancestor: fedb7de8d5fe70aa0cd0ee66f32050b68f5fd230
Author: datallah at pidgin.im
Date: 2008-07-29T03:40:47
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/91d99da9c9328ef874880c805ed522358fba57ba
Modified files:
pidgin/gtkroomlist.c
ChangeLog:
Fix a race related to closing the roomlist window and do some minor cleanup.
The relevant changes are in delete_win_cb().
Fixes #6134
-------------- next part --------------
============================================================
--- pidgin/gtkroomlist.c c93305e14b0798bee63d6ebf7563d294ba0da3b9
+++ pidgin/gtkroomlist.c 3829fbf07b00792ee32ae84e02acc141b30e35b9
@@ -53,7 +53,6 @@ typedef struct _PidginRoomlistDialog {
PurpleRoomlist *roomlist;
gboolean pg_needs_pulse;
- gboolean pg_to_active;
guint pg_update_to;
} PidginRoomlistDialog;
@@ -84,32 +83,34 @@ static gint delete_win_cb(GtkWidget *w,
static gint delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
{
- PidginRoomlistDialog *dialog;
+ PidginRoomlistDialog *dialog = d;
- dialog = (PidginRoomlistDialog *) d;
-
if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist))
purple_roomlist_cancel_get_list(dialog->roomlist);
+ if (dialog->pg_update_to > 0)
+ purple_timeout_remove(dialog->pg_update_to);
+
if (dialog->roomlist) {
- if (dialog->pg_to_active) {
- purple_timeout_remove(dialog->pg_update_to);
- dialog->pg_to_active = FALSE;
+ PidginRoomlist *rl = dialog->roomlist->ui_data;
+
+ if (dialog->pg_update_to > 0)
/* yes, that's right, unref it twice. */
purple_roomlist_unref(dialog->roomlist);
- }
- }
- /* free stuff here */
- if (dialog->roomlist)
+ if (rl)
+ rl->dialog = NULL;
purple_roomlist_unref(dialog->roomlist);
+ }
+
+ dialog->progress = NULL;
g_free(dialog);
return FALSE;
}
static void dialog_select_account_cb(GObject *w, PurpleAccount *account,
- PidginRoomlistDialog *dialog)
+ PidginRoomlistDialog *dialog)
{
dialog->account = account;
}
@@ -186,10 +187,8 @@ selection_changed_cb(GtkTreeSelection *s
GValue val;
PurpleRoomlistRoom *room;
static struct _menu_cb_info *info;
- PidginRoomlistDialog *dialog;
+ PidginRoomlistDialog *dialog = grl->dialog;
- dialog = grl->dialog;
-
if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
val.g_type = 0;
gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val);
@@ -239,10 +238,8 @@ static void add_room_to_blist_cb(GtkButt
{
PurpleRoomlist *rl = dialog->roomlist;
PidginRoomlist *grl = rl->ui_data;
- struct _menu_cb_info *info;
+ struct _menu_cb_info *info = g_object_get_data(G_OBJECT(button), "room-info");
- info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info");
-
if(info != NULL)
do_add_room_cb(grl->tree, info);
}
@@ -256,10 +253,8 @@ static void join_button_cb(GtkButton *bu
{
PurpleRoomlist *rl = dialog->roomlist;
PidginRoomlist *grl = rl->ui_data;
- struct _menu_cb_info *info;
+ struct _menu_cb_info *info = g_object_get_data(G_OBJECT(button), "room-info");
- info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info");
-
if(info != NULL)
do_join_cb(grl->tree, info);
}
@@ -490,12 +485,13 @@ static gboolean account_filter_func(Purp
static gboolean account_filter_func(PurpleAccount *account)
{
- PurpleConnection *gc = purple_account_get_connection(account);
+ PurpleConnection *conn = purple_account_get_connection(account);
PurplePluginProtocolInfo *prpl_info = NULL;
- prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+ if (conn)
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(conn->prpl);
- return (prpl_info->roomlist_get_list != NULL);
+ return (prpl_info && prpl_info->roomlist_get_list != NULL);
}
gboolean
@@ -518,10 +514,7 @@ pidgin_roomlist_dialog_new_with_account(
pidgin_roomlist_dialog_new_with_account(PurpleAccount *account)
{
PidginRoomlistDialog *dialog;
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *vbox2;
- GtkWidget *bbox;
+ GtkWidget *window, *vbox, *vbox2, *bbox;
dialog = g_new0(PidginRoomlistDialog, 1);
dialog->account = account;
@@ -611,9 +604,8 @@ void pidgin_roomlist_dialog_show_with_ac
void pidgin_roomlist_dialog_show_with_account(PurpleAccount *account)
{
- PidginRoomlistDialog *dialog;
+ PidginRoomlistDialog *dialog = pidgin_roomlist_dialog_new_with_account(account);
- dialog = pidgin_roomlist_dialog_new_with_account(account);
if (!dialog)
return;
@@ -627,10 +619,8 @@ static void pidgin_roomlist_new(PurpleRo
static void pidgin_roomlist_new(PurpleRoomlist *list)
{
- PidginRoomlist *rl;
+ PidginRoomlist *rl = g_new0(PidginRoomlist, 1);
- rl = g_new0(PidginRoomlist, 1);
-
list->ui_data = rl;
rl->cats = g_hash_table_new_full(NULL, NULL, NULL, (GDestroyNotify)gtk_tree_row_reference_free);
@@ -802,7 +792,7 @@ static gboolean pidgin_progress_bar_puls
if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) {
if (rl && rl->dialog)
- rl->dialog->pg_to_active = FALSE;
+ rl->dialog->pg_update_to = 0;
purple_roomlist_unref(list);
return FALSE;
}
@@ -827,15 +817,14 @@ static void pidgin_roomlist_add_room(Pur
rl->num_rooms++;
if (rl->dialog) {
- if (!rl->dialog->pg_to_active) {
- rl->dialog->pg_to_active = TRUE;
+ if (rl->dialog->pg_update_to == 0) {
purple_roomlist_ref(list);
rl->dialog->pg_update_to = g_timeout_add(100, pidgin_progress_bar_pulse, list);
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
- } else {
+ } else
rl->dialog->pg_needs_pulse = TRUE;
- }
}
+
if (room->parent) {
parentrr = g_hash_table_lookup(rl->cats, room->parent);
path = gtk_tree_row_reference_get_path(parentrr);
@@ -881,14 +870,14 @@ static void pidgin_roomlist_add_room(Pur
}
}
-static void pidgin_roomlist_in_progress(PurpleRoomlist *list, gboolean flag)
+static void pidgin_roomlist_in_progress(PurpleRoomlist *list, gboolean in_progress)
{
PidginRoomlist *rl = list->ui_data;
if (!rl || !rl->dialog)
return;
- if (flag) {
+ if (in_progress) {
if (rl->dialog->account_widget)
gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE);
gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE);
@@ -905,12 +894,10 @@ static void pidgin_roomlist_destroy(Purp
static void pidgin_roomlist_destroy(PurpleRoomlist *list)
{
- PidginRoomlist *rl;
+ PidginRoomlist *rl = list->ui_data;
roomlists = g_list_remove(roomlists, list);
- rl = list->ui_data;
-
g_return_if_fail(rl != NULL);
g_hash_table_destroy(rl->cats);
More information about the Commits
mailing list