Author: jannis
Date: 2007-10-20 20:23:43 +0000 (Sat, 20 Oct 2007)
New Revision: 26163

Modified:
   libxfce4menu/trunk/ChangeLog
   libxfce4menu/trunk/libxfce4menu/xfce-menu-item-cache.c
   libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c
   libxfce4menu/trunk/libxfce4menu/xfce-menu.c
Log:
        * libxfce4menu/xfce-menu-monitor.c: No, let's do it 
          differently: You can now redefine the vtable. You can also
          clear it by passing NULL. Whenever you want to change the
          user_data, just pass the same vtable as before.
        * libxfce4menu/xfce-menu-item-cache.c: Deactivate the cache
          for now. Perhaps we can add it later, together with fast
          checksum support to detect filesystem changes.
        
        * libxfce4menu/xfce-menu-monitor.c: Add vtable != NULL check
          to xfce_menu_monitor_set_vtable. Avoids crashes when passing
          a NULL pointer and makes other developers aware of what they
          might be doing wrong.
        * STATUS: Updated the status file to reflect the
          current implementation status.

Modified: libxfce4menu/trunk/ChangeLog
===================================================================
--- libxfce4menu/trunk/ChangeLog        2007-10-20 19:46:02 UTC (rev 26162)
+++ libxfce4menu/trunk/ChangeLog        2007-10-20 20:23:43 UTC (rev 26163)
@@ -1,3 +1,25 @@
+2007-10-20     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * libxfce4menu/xfce-menu-monitor.c: No, let's do it 
+         differently: You can now redefine the vtable. You can also
+         clear it by passing NULL. Whenever you want to change the
+         user_data, just pass the same vtable as before.
+       * libxfce4menu/xfce-menu-item-cache.c: Deactivate the cache
+         for now. Perhaps we can add it later, together with fast
+         checksum support to detect filesystem changes.
+       
+2007-10-20     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * libxfce4menu/xfce-menu-monitor.c: Add vtable != NULL check
+         to xfce_menu_monitor_set_vtable. Avoids crashes when passing
+         a NULL pointer and makes other developers aware of what they
+         might be doing wrong.
+
+2007-10-12     Jannis Pohlmann <[EMAIL PROTECTED]>
+
+       * STATUS: Updated the status file to reflect the
+         current implementation status.
+
 2007-09-25     Jannis Pohlmann <[EMAIL PROTECTED]>
 
        * libxfce4menu/xfce-menu-layout.c: As a follow-up to 

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-item-cache.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-item-cache.c      2007-10-20 
19:46:02 UTC (rev 26162)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-item-cache.c      2007-10-20 
20:23:43 UTC (rev 26163)
@@ -61,11 +61,13 @@
 static void          xfce_menu_item_cache_class_init (XfceMenuItemCacheClass 
*klass);
 static void          xfce_menu_item_cache_init       (XfceMenuItemCache      
*cache);
 static void          xfce_menu_item_cache_finalize   (GObject                
*object);
+#if 0 /* ITEM CACHE DEACTIVATED FOR NOW */
 static XfceMenuItem *xfce_menu_item_cache_fetch_item (XfceMenuItemCache      
*cache,
                                                       const gchar            
*filename);
 static void          xfce_menu_item_cache_store_item (XfceMenuItemCache      
*cache,
                                                       const gchar            
*filename,
                                                       XfceMenuItem           
*item);
+#endif
 
 
 
@@ -255,6 +257,7 @@
    * item cache */
   g_mutex_lock (cache->priv->lock);
 
+#if 0
   /* Search filename in the hash table */
   item = g_hash_table_lookup (cache->priv->items, filename);
 
@@ -306,6 +309,7 @@
           return item;
         }
     }
+#endif
 
   /* Last chance is to load it directly from the file */
   item = xfce_menu_item_new (filename);
@@ -315,11 +319,13 @@
       /* Update desktop id */
       xfce_menu_item_set_desktop_id (item, desktop_id);
 
+#if 0 /* ITEM CACHE DEACTIVATED FOR NOW */
       /* Store updated item in cache */
       xfce_menu_item_cache_store_item (cache, filename, item);
 
       /* The file has been loaded, add the item to the hash table */
       g_hash_table_replace (cache->priv->items, g_strdup (filename), item);
+#endif
 
       /* Grab a reference on it but don't increase the allocation counter */
 #if 0
@@ -353,6 +359,7 @@
 
 
 
+#if 0 /* ITEM CACHE DEACTIVATED FOR NOW */
 static XfceMenuItem*
 xfce_menu_item_cache_fetch_item (XfceMenuItemCache *cache,
                                  const gchar       *filename)
@@ -414,3 +421,4 @@
    *   tdb_store (cache->priv->context, key, data, TDB_REPLACE);
    */
 }
+#endif

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c 2007-10-20 19:46:02 UTC 
(rev 26162)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu-monitor.c 2007-10-20 20:23:43 UTC 
(rev 26163)
@@ -30,9 +30,6 @@
 
 
 
-/* Whether the vtable has been set once */
-static gboolean xfce_menu_monitor_vtable_set = FALSE;
-
 /* Initial vtable configuration */
 static XfceMenuMonitorVTable xfce_menu_monitor_vtable = {
   NULL,
@@ -90,24 +87,31 @@
  *
  * Sets the functions to be called when monitoring a file or directory
  * becomes necessary. See #XfceMenuMonitorVTable for more detailled
- * information.
+ * information. Be careful with redefining the #XfceMenuMonitorVTable 
+ * (e.g. don't redefine it while there are any #XfceMenu's around).
+ *
+ * In order to change the user data, just pass the same 
+ * #XfceMenuMonitorVTable as you did before. Pass NULL to clear the
+ * vtable (e.g. if you want to disable monitoring support).
  */
 void
 xfce_menu_monitor_set_vtable (XfceMenuMonitorVTable *vtable,
                               gpointer               user_data)
 {
-  g_return_if_fail (vtable != NULL);
-
-  if (G_LIKELY (!xfce_menu_monitor_vtable_set))
+  if (G_UNLIKELY (vtable == NULL))
     {
-      if (G_UNLIKELY (vtable->monitor_file && vtable->monitor_directory && 
vtable->remove_monitor))
-        {
-          xfce_menu_monitor_vtable.monitor_file = vtable->monitor_file;
-          xfce_menu_monitor_vtable.monitor_directory = 
vtable->monitor_directory;
-          xfce_menu_monitor_vtable.remove_monitor = vtable->remove_monitor;
-          xfce_menu_monitor_user_data = user_data;
-        }
+      xfce_menu_monitor_vtable.monitor_file = NULL;
+      xfce_menu_monitor_vtable.monitor_directory = NULL;
+      xfce_menu_monitor_vtable.remove_monitor = NULL;
     }
+  else
+    {
+      xfce_menu_monitor_vtable.monitor_file = vtable->monitor_file;
+      xfce_menu_monitor_vtable.monitor_directory = vtable->monitor_directory;
+      xfce_menu_monitor_vtable.remove_monitor = vtable->remove_monitor;
+    }
+
+  xfce_menu_monitor_user_data = user_data;
 }
 
 

Modified: libxfce4menu/trunk/libxfce4menu/xfce-menu.c
===================================================================
--- libxfce4menu/trunk/libxfce4menu/xfce-menu.c 2007-10-20 19:46:02 UTC (rev 
26162)
+++ libxfce4menu/trunk/libxfce4menu/xfce-menu.c 2007-10-20 20:23:43 UTC (rev 
26163)
@@ -2666,9 +2666,9 @@
                                 const gchar  *filename,
                                 XfceMenuPair *data)
 {
-  XfceMenu              *menu;
-  XfceMenuStandardRules *rule;
-  XfceMenuItem          *item;
+  XfceMenu              *menu = NULL;
+  XfceMenuStandardRules *rule = NULL;
+  XfceMenuItem          *item = NULL;
 
   g_return_if_fail (XFCE_IS_MENU (data->first));
   g_return_if_fail (XFCE_IS_MENU_STANDARD_RULES (data->second));
@@ -2774,7 +2774,7 @@
         }
     }
 
-#if 0
+#if 0 
   XfceMenu     *submenu;
   XfceMenu     *target_submenu;
   XfceMenuMove *move;

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to