cpw.nader.asynclogging-3: d242f17f: Fixed some locks in log.c not being unlo...

nader.morshed at pidgin.im nader.morshed at pidgin.im
Fri Jan 14 17:01:07 EST 2011


----------------------------------------------------------------------
Revision: d242f17f21b383df08d48ae3c1c77ebd24cb51e1
Parent:   37471838b011f3071671651a94bc05f429ec6b9a
Author:   nader.morshed at pidgin.im
Date:     01/05/11 12:21:11
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/d242f17f21b383df08d48ae3c1c77ebd24cb51e1

Changelog: 

Fixed some locks in log.c not being unlocked when they should have been
Fixed up so last few issues with creating the log viewer for finch

Changes against parent 37471838b011f3071671651a94bc05f429ec6b9a

  patched  finch/gntlog.c
  patched  libpurple/log.c

-------------- next part --------------
============================================================
--- libpurple/log.c	b3de711414b7d83ffd8e3fc08180b01b88ff51e3
+++ libpurple/log.c	b0b025f999a3ed31d95229c835fbcd0a1a65757b
@@ -1095,7 +1095,7 @@ purple_logs_get_total_size(PurpleLogChat
 
 		G_LOCK(logsize_users);
 		g_hash_table_replace(logsize_users, lu, GINT_TO_POINTER(total));
-		G_LOCK(logsize_users);
+		G_UNLOCK(logsize_users);
 	}
 
 	return total;
@@ -1706,12 +1706,10 @@ purple_log_logger_remove(GType log_type)
 			loggers = g_array_remove_index_fast(loggers, i);
 			g_type_class_unref(g_type_class_peek(log_type));
 
-			return;
+			break;
 		}
 	}
 	G_UNLOCK(loggers);
-
-	//warning?
 }
 
 void
============================================================
--- finch/gntlog.c	861da496d43dd436b01f1939316a6951086425ad
+++ finch/gntlog.c	972cbcc824bc3541f3f5e4fc7290df9697a85ef4
@@ -89,7 +89,7 @@ struct _FinchLogViewerPrivate {
 
 	PurpleLogChatType  viewer_type;    /**< The log type of the window */
 	gboolean           need_log_size;
-	GntWidget          *title_box;
+	GntWidget          *view_box;
 	gchar              *title;
 };
 
@@ -118,6 +118,7 @@ static const gchar *log_get_date(PurpleL
 static guint log_viewer_hash(gconstpointer);
 static gboolean log_viewer_equal(gconstpointer, gconstpointer);
 static const gchar *log_get_date(PurpleLog *);
+static FinchLogViewer *finch_log_viewer_new(log_viewer_hash_t *, const gchar *, gboolean);
 static void finch_log_search_done_cb(_finch_log_data *);
 static void finch_log_search_cb(GObject *, GAsyncResult *, gpointer);
 static void search_cb(GntWidget *, FinchLogViewer *);
@@ -219,12 +220,12 @@ finch_log_search_done_cb(_finch_log_data
 static void
 finch_log_search_done_cb(_finch_log_data *finch_log_data)
 {
-//	if (finch_log_data->is_window_open) {
-//		FinchLogViewer *lv = finch_log_data->log_viewer;
-//
-//		gnt_widget_hide(finch_log_viewer_get_search_bar(lv));
-//	}
+/*	if (finch_log_data->is_window_open) {
+		FinchLogViewer *lv = finch_log_data->log_viewer;
 
+		gnt_widget_hide(finch_log_viewer_get_search_bar(lv));
+	}*/
+
 	finch_log_data_free(finch_log_data);
 }
 
@@ -317,7 +318,7 @@ search_cb(GntWidget *button, FinchLogVie
 		"destroy", G_CALLBACK(finch_window_destroy_cb), finch_log_data);
 
 	bar = finch_log_viewer_get_search_bar(lv);
-	// gnt_widget_show(bar);
+	/* gnt_widget_show(bar);*/
 	gnt_progress_bar_set_fraction(GNT_PROGRESS_BAR(bar), 0.0);
 
 	cancel = g_cancellable_new();
@@ -345,8 +346,6 @@ destroy_cb(FinchLogViewer *lv, log_viewe
 		syslog_viewer = NULL;
 		G_UNLOCK(syslog_viewer);
 	}
-
-	gnt_widget_destroy(GNT_WIDGET(lv));
 }
 
 static void
@@ -515,7 +514,7 @@ finch_log_viewer_new(log_viewer_hash_t *
 		G_UNLOCK(log_viewers);
 	}
 
-	g_signal_connect(lv, "response", G_CALLBACK(destroy_cb), ht);
+	g_signal_connect(lv, "destroy", G_CALLBACK(destroy_cb), ht);
 
 	return lv;
 }
@@ -525,10 +524,10 @@ finch_log_done_cb(_finch_log_data *finch
 {
 	if (finch_log_data->is_window_open) {
 		FinchLogViewer *lv = finch_log_data->log_viewer;
-//		GntWidget *bar = finch_log_viewer_get_list_bar(lv);
+/*		GntWidget *bar = finch_log_viewer_get_list_bar(lv);*/
 		GList *logs = finch_log_viewer_get_logs(lv);
 
-//		gnt_widget_hide(bar);
+/*		gnt_widget_hide(bar);*/
 
 		if (logs == NULL) {
 			/* No logs were found. */
@@ -1050,6 +1049,7 @@ finch_log_viewer_add_logs(FinchLogViewer
 	priv = FINCH_LOG_VIEWER_GET_PRIVATE(lv);
 
 	priv->logs = g_list_concat(priv->logs, logs);
+	priv->logs = g_list_sort(priv->logs, purple_log_compare);
 	populate_log_tree(lv);
 
 	g_object_notify(G_OBJECT(lv), "logs");
@@ -1219,7 +1219,8 @@ finch_log_viewer_constructed(GObject *ob
 finch_log_viewer_constructed(GObject *object)
 {
 	FinchLogViewer *lv = FINCH_LOG_VIEWER(object);
-	PidginLogViewerPrivate *priv = PIDGIN_LOG_VIEWER_GET_PRIVATE(lv);
+	FinchLogViewerPrivate *priv = FINCH_LOG_VIEWER_GET_PRIVATE(lv);
+	gboolean need_log_size;
 
 	/* Log size */
 	need_log_size = finch_log_viewer_get_need_log_size(lv);
@@ -1232,13 +1233,12 @@ finch_log_viewer_constructed(GObject *ob
 		text = g_strdup_printf("%s %s", _("Total log size:"), _("calculating..."));
 
 		priv->size_label = gnt_label_new(text);
-		gnt_box_add_widget(GNT_BOX(hbox), priv->size_label);
+		gnt_box_add_widget(GNT_BOX(priv->view_box), priv->size_label);
 
 		g_free(text);
 	}
 
 	/* Hook up all the signals */
-	g_signal_connect(lv, "destroy", G_CALLBACK(destroy_cb), ht);
 	g_signal_connect(priv->tree, "selection-changed", G_CALLBACK(log_select_cb), lv);
 	g_signal_connect(priv->entry, "activate", G_CALLBACK(search_cb), lv);
 }
@@ -1524,6 +1524,7 @@ finch_log_viewer_init(FinchLogViewer *lv
 static void
 finch_log_viewer_init(FinchLogViewer *lv)
 {
+	FinchLogViewerPrivate *priv = FINCH_LOG_VIEWER_GET_PRIVATE(lv);
 	GntBox *box = GNT_BOX(lv);
 	GntWidget *vbox, *hbox;
 
@@ -1538,21 +1539,21 @@ finch_log_viewer_init(FinchLogViewer *lv
 
 	/* Label */
 	/* Fixme: get the title for this here or move it to constructed */
-	priv->label = gnt_label_new_with_format(NULL, GNT_TEXT_FLAG_BOLD);
+	priv->label = gnt_label_new_with_format("", GNT_TEXT_FLAG_BOLD);
 	gnt_box_add_widget(GNT_BOX(vbox), priv->label);
 
 	/* Box for tree and text view */
-	hbox = gnt_hbox_new(FALSE);
-	gnt_box_add_widget(GNT_BOX(vbox), hbox);
+	priv->view_box = gnt_hbox_new(FALSE);
+	gnt_box_add_widget(GNT_BOX(vbox), priv->view_box);
 
 	/* List */
 	priv->tree = gnt_tree_new();
 	gnt_widget_set_size(priv->tree, 30, 0);
-	gnt_box_add_widget(GNT_BOX(hbox), priv->tree);
+	gnt_box_add_widget(GNT_BOX(priv->view_box), priv->tree);
 
 	/* Viewer */
 	priv->text = gnt_text_view_new();
-	gnt_box_add_widget(GNT_BOX(hbox), priv->text);
+	gnt_box_add_widget(GNT_BOX(priv->view_box), priv->text);
 	gnt_text_view_set_flag(GNT_TEXT_VIEW(priv->text), GNT_TEXT_VIEW_TOP_ALIGN);
 
 	/* Box for search entry */
@@ -1576,7 +1577,7 @@ finch_log_viewer_init(FinchLogViewer *lv
 	gnt_box_add_widget(GNT_BOX(vbox), priv->list_bar);
 	gnt_box_add_widget(GNT_BOX(vbox), priv->search_bar);
 
-	gnt_widget_show(lv);
+	gnt_widget_show(GNT_WIDGET(lv));
 /*	gnt_widget_show_all(lv);
 	gnt_widget_hide(lv);
 	gnt_widget_hide(priv->search_bar);*/
@@ -1607,7 +1608,7 @@ finch_log_init(void)
 	void *handle = finch_log_get_handle();
 
 	G_LOCK(log_viewers);
-	// Is the ht stuff leaking?
+	/* Is the ht stuff leaking? */
 	log_viewers = g_hash_table_new_full(log_viewer_hash, log_viewer_equal, NULL, g_object_unref);
 	G_UNLOCK(log_viewers);
 


More information about the Commits mailing list