Index: gnome-menus-3.13.3/libmenu/menu-monitor.c
===================================================================
--- gnome-menus-3.13.3.orig/libmenu/menu-monitor.c
+++ gnome-menus-3.13.3/libmenu/menu-monitor.c
@@ -52,6 +52,13 @@ typedef struct
guint refcount;
} MenuMonitorNotify;
+typedef struct
+{
+ MenuMonitor *menu_monitor;
+ GFile *child;
+ GFileMonitorEvent eflags;
+} MonitorCallbackInfo;
+
static MenuMonitorNotify *menu_monitor_notify_ref (MenuMonitorNotify *notify);
static void menu_monitor_notify_unref (MenuMonitorNotify *notify);
@@ -160,18 +167,25 @@ get_registry_key (const char *path,
}
static gboolean
-monitor_callback (GFileMonitor *monitor,
- GFile *child,
- GFile *other_file,
- GFileMonitorEvent eflags,
- gpointer user_data)
+monitor_callback_delayed (gpointer user_data)
{
+ MonitorCallbackInfo *info;
MenuMonitorEventInfo *event_info;
MenuMonitorEvent event;
- MenuMonitor *menu_monitor = (MenuMonitor *) user_data;
+ MenuMonitor *menu_monitor;
+
+ info = (MonitorCallbackInfo *) user_data;
+ menu_monitor = info->menu_monitor;
+
+ if (!menu_monitor)
+ {
+ g_object_unref (info->child);
+ g_free (info);
+ return TRUE;
+ }
event = MENU_MONITOR_EVENT_INVALID;
- switch (eflags)
+ switch (info->eflags)
{
case G_FILE_MONITOR_EVENT_CHANGED:
event = MENU_MONITOR_EVENT_CHANGED;
@@ -183,17 +197,43 @@ monitor_callback (GFileMonitor *mon
event = MENU_MONITOR_EVENT_DELETED;
break;
default:
+ g_object_unref (info->child);
+ g_free (info);
return TRUE;
}
event_info = g_new0 (MenuMonitorEventInfo, 1);
- event_info->path = g_file_get_path (child);
+ event_info->path = g_file_get_path (info->child);
event_info->event = event;
event_info->monitor = menu_monitor;
menu_monitor_queue_event (event_info);
+ g_object_unref (info->child);
+ g_free (info);
+ return TRUE;
+}
+
+static gboolean
+monitor_callback (GFileMonitor *monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent eflags,
+ gpointer user_data)
+{
+ MenuMonitor *menu_monitor;
+ MonitorCallbackInfo *info;
+
+ menu_monitor = (MenuMonitor *) user_data;
+
+ info = g_new0 (MonitorCallbackInfo, 1);
+ g_object_add_weak_pointer (menu_monitor, &info->menu_monitor);
+ info->child = g_object_ref (child);
+ info->eflags = eflags;
+
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 2, monitor_callback_delayed, info, NULL);
+
return TRUE;
}