[Xfce4-commits] r29738 - in xfce4-panel/trunk: . plugins/launcher

Nick Schermer nick at xfce.org
Thu Apr 9 20:45:57 CEST 2009


Author: nick
Date: 2009-04-09 18:45:56 +0000 (Thu, 09 Apr 2009)
New Revision: 29738

Modified:
   xfce4-panel/trunk/NEWS
   xfce4-panel/trunk/plugins/launcher/launcher-exec.c
   xfce4-panel/trunk/plugins/launcher/launcher.c
Log:
Don't crash the launcher plugin when the launcher entry list is empty.


Modified: xfce4-panel/trunk/NEWS
===================================================================
--- xfce4-panel/trunk/NEWS	2009-04-09 18:33:21 UTC (rev 29737)
+++ xfce4-panel/trunk/NEWS	2009-04-09 18:45:56 UTC (rev 29738)
@@ -5,6 +5,7 @@
 - Don't crash when the quit action button is pressed (bug #5118).
 - Properly set the systray orientation property (bug #5149).
 - Fix xfce-hvbox not working with gtk 2.16 (bug #5166).
+- Don't crash the launcher plugin when the launcher entry list is empty.
 
 
 4.6.0

Modified: xfce4-panel/trunk/plugins/launcher/launcher-exec.c
===================================================================
--- xfce4-panel/trunk/plugins/launcher/launcher-exec.c	2009-04-09 18:33:21 UTC (rev 29737)
+++ xfce4-panel/trunk/plugins/launcher/launcher-exec.c	2009-04-09 18:45:56 UTC (rev 29738)
@@ -603,6 +603,10 @@
     GSList   *li;
     GSList    fake;
     gboolean  proceed = TRUE;
+    
+    /* leave when entry is null */
+    if (G_UNLIKELY (entry == NULL))
+        return;
 
     /* be secure */
     if (G_UNLIKELY (screen == NULL))

Modified: xfce4-panel/trunk/plugins/launcher/launcher.c
===================================================================
--- xfce4-panel/trunk/plugins/launcher/launcher.c	2009-04-09 18:33:21 UTC (rev 29737)
+++ xfce4-panel/trunk/plugins/launcher/launcher.c	2009-04-09 18:45:56 UTC (rev 29738)
@@ -353,9 +353,16 @@
     GdkPixbuf     *pixbuf;
     LauncherEntry *entry;
     GdkScreen     *screen;
+    GList         *first = g_list_first (launcher->entries);
+    
+    /* leave when there is no list item */
+    if (G_UNLIKELY (first == NULL))
+        return;
 
     /* get the first entry in the list */
-    entry = g_list_first (launcher->entries)->data;
+    entry = first->data;
+    if (G_UNLIKELY (entry == NULL))
+        return;
 
     /* get widget screen */
     screen = gtk_widget_get_screen (launcher->image);
@@ -387,12 +394,15 @@
                                     GtkTooltip     *tooltip,
                                     LauncherPlugin *launcher)
 {
+    GList *first = g_list_first (launcher->entries);
+    
     /* don't show tooltips on a menu button */
-    if (launcher->arrow_position == LAUNCHER_ARROW_INSIDE_BUTTON)
-       return FALSE;
+    if (launcher->arrow_position == LAUNCHER_ARROW_INSIDE_BUTTON
+        || first == NULL)
+        return FALSE;
 
     return launcher_utility_query_tooltip (widget, x, y, keyboard_mode, tooltip,
-                                           g_list_first (launcher->entries)->data);
+                                           first->data);
 }
 
 
@@ -403,12 +413,19 @@
 {
     LauncherEntry *entry;
     gchar         *string = NULL;
+    GList         *first = g_list_first (launcher->entries);
+    
+    /* leave when there is no entry */
+    if (G_UNLIKELY (first == NULL))
+        return;
 
     /* get first entry */
-    entry = g_list_first (launcher->entries)->data;
+    entry = first->data;
 
     /* create tooltip text */
-    if (G_LIKELY (entry->name && launcher->arrow_position != LAUNCHER_ARROW_INSIDE_BUTTON))
+    if (entry != NULL
+        && entry->name 
+        && launcher->arrow_position != LAUNCHER_ARROW_INSIDE_BUTTON))
     {
         if (entry->comment)
             string = g_strdup_printf ("%s\n%s", entry->name, entry->comment);
@@ -464,6 +481,7 @@
 {
     LauncherEntry *entry;
     GdkScreen     *screen;
+    GList         *first;
 
     /* remove the timeout */
     if (G_LIKELY (launcher->popup_timeout_id > 0))
@@ -473,7 +491,10 @@
     if (GTK_BUTTON (button)->in_button && launcher->arrow_position != LAUNCHER_ARROW_INSIDE_BUTTON)
     {
         /* get the first launcher entry */
-        entry = g_list_first (launcher->entries)->data;
+        first = g_list_first (launcher->entries);
+        if (G_UNLIKELY (first == NULL))
+            return FALSE;
+        entry = first->data;
 
         /* get the widget screen */
         screen = gtk_widget_get_screen (button);
@@ -502,6 +523,7 @@
 {
     GSList        *filenames;
     LauncherEntry *entry;
+    GList         *first;
 
     /* execute */
     if (launcher->arrow_position != LAUNCHER_ARROW_INSIDE_BUTTON)
@@ -512,7 +534,10 @@
         if (G_LIKELY (filenames))
         {
             /* get entry */
-            entry = g_list_first (launcher->entries)->data;
+            first = g_list_first (launcher->entries);
+            if (G_UNLIKELY (first == NULL))
+                return;
+            entry = first->data;
 
             /* execute the entry with the filenames */
             launcher_execute (gtk_widget_get_screen (widget), entry, filenames, time_);
@@ -680,6 +705,7 @@
 
         /* move the item to the first position in the list */
         if (launcher->move_first
+            && launcher->entries != NULL
             && launcher->entries->data != entry)
         {
             /* remove from the list */




More information about the Xfce4-commits mailing list