changeset 2224:54912b5d142d

Reapply 'call notify functions in in an idle call' 085be43cb79e04341102a9922e0e0f531454089a did some regression that should have fixed this.
author Klaus Ethgen <Klaus@Ethgen.de>
date Tue, 02 Oct 2012 23:07:47 +0100
parents bd7591bd8dc2
children 4617e1d83e9b
files src/filedata.c
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Tue Oct 02 22:49:52 2012 +0100
+++ b/src/filedata.c	Tue Oct 02 23:07:47 2012 +0100
@@ -2638,6 +2638,12 @@
    implementation in view_file_list.c */
 
 
+typedef struct _NotifyIdleData NotifyIdleData;
+
+struct _NotifyIdleData {
+	FileData *fd;
+	NotifyType type;
+};
 
 
 typedef struct _NotifyData NotifyData;
@@ -2711,17 +2717,29 @@
 }
 
 
-void file_data_send_notification(FileData *fd, NotifyType type)
+gboolean file_data_send_notification_idle_cb(gpointer data)
 {
+	NotifyIdleData *nid = (NotifyIdleData *)data;
 	GList *work = notify_func_list;
 
 	while (work)
 		{
 		NotifyData *nd = (NotifyData *)work->data;
 
-		nd->func(fd, type, nd->data);
+		nd->func(nid->fd, nid->type, nd->data);
 		work = work->next;
 		}
+	file_data_unref(nid->fd);
+	g_free(nid);
+	return FALSE;
+}
+
+void file_data_send_notification(FileData *fd, NotifyType type)
+{
+	NotifyIdleData *nid = g_new0(NotifyIdleData, 1);
+	nid->fd = file_data_ref(fd);
+	nid->type = type;
+	g_idle_add_full(G_PRIORITY_HIGH, file_data_send_notification_idle_cb, nid, NULL);
 }
 
 static GHashTable *file_data_monitor_pool = NULL;