[Xfce4-commits] <xfdesktop:master> Fix some potential bugs

Eric Koegel noreply at xfce.org
Sat Jan 25 06:50:01 CET 2014


Updating branch refs/heads/master
         to 78393c501d071ec05986d62b210b26e0170942ad (commit)
       from da61495218044db15bf95c4f2184ec969dc50c7a (commit)

commit 78393c501d071ec05986d62b210b26e0170942ad
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sat Jan 25 08:32:29 2014 +0300

    Fix some potential bugs
    
    Correct some of the issues found with coverity scan. Things like
    an unused pointer, variables that could potentially be used in an
    uninitialized state, a copy-paste error, and a couple spots where
    the return value wasn't checked.

 common/xfdesktop-thumbnailer.c    |   10 +++++-----
 settings/main.c                   |    4 ++--
 src/xfce-workspace.c              |    2 +-
 src/xfdesktop-file-icon-manager.c |   12 +++++++++---
 src/xfdesktop-file-utils.c        |    2 +-
 src/xfdesktop-icon-view.c         |   13 +++++++++----
 src/xfdesktop-volume-icon.c       |    1 -
 7 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/common/xfdesktop-thumbnailer.c b/common/xfdesktop-thumbnailer.c
index 248a3c5..f49edb2 100644
--- a/common/xfdesktop-thumbnailer.c
+++ b/common/xfdesktop-thumbnailer.c
@@ -216,13 +216,13 @@ xfdesktop_thumbnailer_dispose(GObject *object)
 {
     XfdesktopThumbnailer *thumbnailer = XFDESKTOP_THUMBNAILER(object);
 
-    if(thumbnailer->priv->proxy)
-        g_object_unref(thumbnailer->priv->proxy);
+    if(thumbnailer->priv) {
+        if(thumbnailer->priv->proxy)
+            g_object_unref(thumbnailer->priv->proxy);
 
-    if(thumbnailer->priv->supported_mimetypes)
-        g_free(thumbnailer->priv->supported_mimetypes);
+        if(thumbnailer->priv->supported_mimetypes)
+            g_free(thumbnailer->priv->supported_mimetypes);
 
-    if(thumbnailer->priv) {
         g_free(thumbnailer->priv);
         thumbnailer->priv = NULL;
     }
diff --git a/settings/main.c b/settings/main.c
index dec5ea4..41e4d5c 100644
--- a/settings/main.c
+++ b/settings/main.c
@@ -1276,12 +1276,12 @@ xfdesktop_settings_background_tab_change_bindings(AppearancePanel *panel,
         /* If the first color doesn't exist, try to load the old one */
         if(!xfconf_channel_has_property(channel, buf)) {
             GValue value = { 0, };
-            old_property = xfdesktop_settings_generate_old_binding_string(panel, "color1");
+            old_property = xfdesktop_settings_generate_old_binding_string(panel, "color2");
 
             xfconf_channel_get_property(channel, old_property, &value);
 
             if(G_VALUE_HOLDS_BOXED(&value)) {
-                gtk_color_button_set_color(GTK_COLOR_BUTTON(panel->color1_btn),
+                gtk_color_button_set_color(GTK_COLOR_BUTTON(panel->color2_btn),
                                            g_value_get_boxed(&value));
                 g_value_unset(&value);
             } else {
diff --git a/src/xfce-workspace.c b/src/xfce-workspace.c
index 0a9f84a..13aa924 100644
--- a/src/xfce-workspace.c
+++ b/src/xfce-workspace.c
@@ -145,7 +145,7 @@ xfce_workspace_change_backdrop(XfceWorkspace *workspace,
     XfconfChannel *channel = workspace->priv->channel;
     char buf[1024];
     gchar *monitor_name = NULL;
-    guint i, monitor_num;
+    guint i, monitor_num = 0;
 
     g_return_if_fail(workspace->priv->nbackdrops > 0);
 
diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index a3201e6..7870635 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -2456,7 +2456,7 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor     *monitor,
     XfdesktopFileIconManager *fmanager = XFDESKTOP_FILE_ICON_MANAGER(user_data);
     XfdesktopFileIcon *icon, *moved_icon;
     GFileInfo *file_info;
-    guint16 row, col;
+    guint16 row = 0, col = 0;
     gchar *filename;
 
     switch(event) {
@@ -2470,7 +2470,10 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor     *monitor,
 
             if(icon) {
                 /* Get the old position so we can use it for the new icon */
-                xfdesktop_icon_get_position(XFDESKTOP_ICON(icon), &row, &col);
+                if(!xfdesktop_icon_get_position(XFDESKTOP_ICON(icon), &row, &col)) {
+                    /* Failed to get position... not supported? */
+                    row = col = 0;
+                }
                 DBG("row %d, col %d", row, col);
 
                 /* Remove the old icon */
@@ -2484,7 +2487,10 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor     *monitor,
             if(moved_icon) {
                 /* Since we're replacing an existing icon, get that location
                  * to use instead */
-                xfdesktop_icon_get_position(XFDESKTOP_ICON(moved_icon), &row, &col);
+                if(!xfdesktop_icon_get_position(XFDESKTOP_ICON(icon), &row, &col)) {
+                    /* Failed to get position... not supported? */
+                    row = col = 0;
+                }
                 DBG("row %d, col %d", row, col);
 
                 xfdesktop_file_icon_manager_remove_icon(fmanager, moved_icon);
diff --git a/src/xfdesktop-file-utils.c b/src/xfdesktop-file-utils.c
index 94df3a2..91ab61e 100644
--- a/src/xfdesktop-file-utils.c
+++ b/src/xfdesktop-file-utils.c
@@ -441,7 +441,7 @@ xfdesktop_file_utils_get_icon(GIcon *icon,
 static void
 xfdesktop_file_utils_add_emblems(GdkPixbuf *pix, GList *emblems)
 {
-    GdkPixbuf *emblem_pix;
+    GdkPixbuf *emblem_pix = NULL;
     gint max_emblems;
     gint pix_width, pix_height;
     gint emblem_size;
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index fc5af70..5b81528 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -3080,8 +3080,11 @@ xfdesktop_icon_view_paint_icon(XfdesktopIconView *icon_view,
 
     cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
     
-    xfdesktop_icon_get_extents(icon, &pixbuf_extents,
-                               &text_extents, &total_extents);
+    if(!xfdesktop_icon_get_extents(icon, &pixbuf_extents,
+                                   &text_extents, &total_extents))
+    {
+        g_warning("Can't get extents for icon '%s'", xfdesktop_icon_peek_label(icon));
+    }
 
     if(!xfdesktop_icon_view_update_icon_extents(icon_view, icon,
                                                 &pixbuf_extents,
@@ -3170,8 +3173,10 @@ xfdesktop_icon_view_paint_icon(XfdesktopIconView *icon_view,
         GdkRectangle cell = { 0, };
         guint16 row, col;
 
-        xfdesktop_icon_get_position(icon, &row, &col);
-        DBG("for icon at (%hu,%hu) (%s)", row, col, xfdesktop_icon_peek_label(icon));
+        if(!xfdesktop_icon_get_position(icon, &row, &col))
+            DBG("can't get icon position for '%s'", xfdesktop_icon_peek_label(icon));
+        else
+            DBG("for icon at (%hu,%hu) (%s)", row, col, xfdesktop_icon_peek_label(icon));
 
         cairo_set_line_width(cr, 1.0);
 
diff --git a/src/xfdesktop-volume-icon.c b/src/xfdesktop-volume-icon.c
index 66a0b36..f5e8c71 100644
--- a/src/xfdesktop-volume-icon.c
+++ b/src/xfdesktop-volume-icon.c
@@ -807,7 +807,6 @@ xfdesktop_volume_icon_populate_context_menu(XfdesktopIcon *icon,
     const gchar *icon_name, *icon_label;
 
     icon_name = GTK_STOCK_OPEN;
-    icon_label = _("_Open");
 
     img = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
     gtk_widget_show(img);


More information about the Xfce4-commits mailing list