[gthumb] fixed minor memory leaks



commit 258aa30733fbb9d1f897f49702c2b054874dd092
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Apr 3 18:18:28 2017 +0200

    fixed minor memory leaks

 extensions/facebook/facebook-service.c             |    2 ++
 extensions/file_manager/callbacks.c                |    5 ++++-
 extensions/flicker_utils/flickr-service.c          |    2 ++
 .../image_viewer/gth-metadata-provider-image.c     |    5 +++++
 extensions/photobucket/photobucket-service.c       |    2 ++
 extensions/picasaweb/picasa-web-service.c          |    5 ++++-
 gthumb/gnome-desktop-thumbnail.c                   |    6 +++++-
 gthumb/gth-application.c                           |    1 +
 gthumb/gth-browser.c                               |   13 +++++++++----
 gthumb/gth-empty-list.c                            |    2 ++
 gthumb/gth-folder-tree.c                           |   10 +++++++---
 gthumb/gth-menu-manager.c                          |    6 +++++-
 gthumb/gth-window.c                                |    3 ++-
 13 files changed, 50 insertions(+), 12 deletions(-)
---
diff --git a/extensions/facebook/facebook-service.c b/extensions/facebook/facebook-service.c
index 09bf484..689d600 100644
--- a/extensions/facebook/facebook-service.c
+++ b/extensions/facebook/facebook-service.c
@@ -804,6 +804,8 @@ upload_photo_file_buffer_ready_cb (void     **buffer,
                }
 
                g_list_free (keys);
+               g_free (description);
+               g_free (title);
                g_hash_table_unref (data_set);
        }
 
diff --git a/extensions/file_manager/callbacks.c b/extensions/file_manager/callbacks.c
index 892ac8b..932854f 100644
--- a/extensions/file_manager/callbacks.c
+++ b/extensions/file_manager/callbacks.c
@@ -1064,6 +1064,8 @@ _gth_browser_update_open_menu (GthBrowser *browser)
                else
                        g_menu_item_set_icon (item, icon);
                g_menu_append_item (data->open_with_menu, item);
+
+               g_object_unref (item);
        }
 
        gth_window_enable_action (GTH_WINDOW (browser), "open-with-application", data->applications != NULL);
@@ -1155,7 +1157,7 @@ fm__gth_browser_file_list_key_press_cb (GthBrowser  *browser,
                                 * for example: when viewing a catalog removes
                                 * the files from the catalog; when viewing a
                                 * folder removes the files from the folder. */
-                               source = gth_browser_get_location_source (browser);
+                               source = _g_object_ref (gth_browser_get_location_source (browser));
                                location = gth_browser_get_location_data (browser);
                        }
                        else {
@@ -1183,6 +1185,7 @@ fm__gth_browser_file_list_key_press_cb (GthBrowser  *browser,
 
                        _g_object_list_unref (file_data_list);
                        _gtk_tree_path_list_free (items);
+                       _g_object_unref (source);
                }
                break;
        }
diff --git a/extensions/flicker_utils/flickr-service.c b/extensions/flicker_utils/flickr-service.c
index 7104729..0336fa1 100644
--- a/extensions/flicker_utils/flickr-service.c
+++ b/extensions/flicker_utils/flickr-service.c
@@ -1372,6 +1372,8 @@ post_photo_file_buffer_ready_cb (void     **buffer,
 
                g_free (tags);
                g_list_free (keys);
+               g_free (description);
+               g_free (title);
                g_hash_table_unref (data_set);
        }
 
diff --git a/extensions/image_viewer/gth-metadata-provider-image.c 
b/extensions/image_viewer/gth-metadata-provider-image.c
index 13b45ea..e45fcda 100644
--- a/extensions/image_viewer/gth-metadata-provider-image.c
+++ b/extensions/image_viewer/gth-metadata-provider-image.c
@@ -63,6 +63,7 @@ gth_metadata_provider_image_read (GthMetadataProvider *self,
        gboolean          format_recognized;
        GFileInputStream *stream;
        char             *description = NULL;
+       gboolean          free_description = FALSE;
        int               width;
        int               height;
        const char       *mime_type = NULL;
@@ -229,6 +230,7 @@ gth_metadata_provider_image_read (GthMetadataProvider *self,
                        if (format != NULL) {
                                format_recognized = TRUE;
                                description = gdk_pixbuf_format_get_description (format);
+                               free_description = TRUE;
                        }
 
                        g_free (filename);
@@ -253,6 +255,9 @@ gth_metadata_provider_image_read (GthMetadataProvider *self,
 
                g_free (size);
        }
+
+       if (free_description)
+               g_free (description);
 }
 
 
diff --git a/extensions/photobucket/photobucket-service.c b/extensions/photobucket/photobucket-service.c
index 2e650a4..ba5a0df 100644
--- a/extensions/photobucket/photobucket-service.c
+++ b/extensions/photobucket/photobucket-service.c
@@ -613,6 +613,8 @@ upload_photo_file_buffer_ready_cb (void     **buffer,
                g_list_free (keys);
                g_free (url);
                g_free (s_size);
+               g_free (description);
+               g_free (title);
                g_hash_table_unref (data_set);
        }
 
diff --git a/extensions/picasaweb/picasa-web-service.c b/extensions/picasaweb/picasa-web-service.c
index 8fb31c5..348d146 100644
--- a/extensions/picasaweb/picasa-web-service.c
+++ b/extensions/picasaweb/picasa-web-service.c
@@ -977,11 +977,14 @@ post_photo_file_buffer_ready_cb (void     **buffer,
                value = gth_file_data_get_attribute_as_string (file_data, "general::title");
        dom_element_append_child (entry,
                                  dom_document_create_element_with_text (doc, value, "summary", NULL));
+       g_free (value);
 
        value = gth_file_data_get_attribute_as_string (file_data, "general::location");
-       if (value != NULL)
+       if (value != NULL) {
                dom_element_append_child (entry,
                                          dom_document_create_element_with_text (doc, value, 
"gphoto:location", NULL));
+               g_free (value);
+       }
 
        metadata = g_file_info_get_attribute_object (file_data->info, "general::tags");
        if (metadata != NULL)
diff --git a/gthumb/gnome-desktop-thumbnail.c b/gthumb/gnome-desktop-thumbnail.c
index 14d1eee..71e4ef1 100644
--- a/gthumb/gnome-desktop-thumbnail.c
+++ b/gthumb/gnome-desktop-thumbnail.c
@@ -665,6 +665,7 @@ external_thumbnailers_disabled_all_changed_cb (GSettings                    *set
                factory->priv->disabled_types = NULL;
        }
        else {
+               g_strfreev (factory->priv->disabled_types);
                factory->priv->disabled_types = g_settings_get_strv (factory->priv->settings, "disable");
                gnome_desktop_thumbnail_factory_load_thumbnailers (factory);
        }
@@ -697,8 +698,10 @@ gnome_desktop_thumbnail_factory_init_scripts (GnomeDesktopThumbnailFactory *fact
                                                               (GDestroyNotify)thumbnailer_unref);
        factory->priv->settings = g_settings_new ("org.gnome.desktop.thumbnailers");
        factory->priv->disabled = g_settings_get_boolean (factory->priv->settings, "disable-all");
-       if (! factory->priv->disabled)
+       if (! factory->priv->disabled) {
+               g_strfreev (factory->priv->disabled_types);
                factory->priv->disabled_types = g_settings_get_strv (factory->priv->settings, "disable");
+       }
        g_signal_connect (factory->priv->settings,
                          "changed::disable-all",
                          G_CALLBACK (external_thumbnailers_disabled_all_changed_cb),
@@ -782,6 +785,7 @@ gnome_desktop_thumbnail_factory_init (GnomeDesktopThumbnailFactory *factory)
 {
        factory->priv = GNOME_DESKTOP_THUMBNAIL_FACTORY_GET_PRIVATE (factory);
        factory->priv->size = GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL;
+       factory->priv->disabled_types = NULL;
        g_mutex_init (&factory->priv->lock);
 
        gnome_desktop_thumbnail_factory_init_scripts (factory);
diff --git a/gthumb/gth-application.c b/gthumb/gth-application.c
index 6eb18fd..6a074d7 100644
--- a/gthumb/gth-application.c
+++ b/gthumb/gth-application.c
@@ -300,6 +300,7 @@ gth_application_command_line (GApplication            *application,
                return EXIT_FAILURE;
        }
        g_option_context_free (context);
+       g_strfreev (argv);
 
        gdk_notify_startup_complete ();
 
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index acaf8ae..650a958 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -2593,6 +2593,7 @@ gth_browser_finalize (GObject *object)
 {
        GthBrowser *browser = GTH_BROWSER (object);
 
+       g_list_free (browser->priv->fixed_viewer_controls);
        g_hash_table_destroy (browser->priv->menu_managers);
        browser_state_free (&browser->priv->state);
        _g_object_unref (browser->priv->browser_settings);
@@ -2760,20 +2761,21 @@ folder_tree_drag_motion_cb (GtkWidget      *file_view,
        /* use COPY if dropping a file in a catalog */
 
        if (action == GDK_ACTION_MOVE) {
-               GthFileData   *destination;
-               GthFileSource *file_source;
+               GthFileData *destination;
 
                destination = gth_folder_tree_get_file (GTH_FOLDER_TREE (browser->priv->folder_tree), path);
                if (destination != NULL) {
-                       file_source = gth_main_get_file_source (destination->file);
-                       _g_object_unref (destination);
+                       GthFileSource *file_source = gth_main_get_file_source (destination->file);
 
+                       _g_object_unref (destination);
                        if (file_source != NULL) {
                                if (gth_file_source_is_reorderable (file_source))
                                        action = GDK_ACTION_COPY;
                        }
                        else
                                action = 0;
+
+                       _g_object_unref (file_source);
                }
                else
                        action = 0;
@@ -3036,6 +3038,8 @@ folder_tree_rename_cb (GthFolderTree *folder_tree,
 
        file_source = gth_main_get_file_source (file);
        gth_file_source_rename (file_source, file, new_name, file_source_rename_ready_cb, browser);
+
+       g_object_unref (file_source);
 }
 
 
@@ -7041,6 +7045,7 @@ _g_menu_item_new_for_file (GFile      *file,
        }
 
        _g_object_unref (info);
+       _g_object_unref (file_source);
 
        return item;
 }
diff --git a/gthumb/gth-empty-list.c b/gthumb/gth-empty-list.c
index ff8b892..6d7e31b 100644
--- a/gthumb/gth-empty-list.c
+++ b/gthumb/gth-empty-list.c
@@ -239,6 +239,8 @@ gth_empty_list_draw (GtkWidget *widget,
                gdk_cairo_set_source_rgba (cr, &color);
                gtk_render_layout (style_context, cr, 0, (allocation.height - bounds.height) / 2, 
self->priv->layout);
                cairo_fill (cr);
+
+               pango_font_description_free (font);
        }
 
        return FALSE;
diff --git a/gthumb/gth-folder-tree.c b/gthumb/gth-folder-tree.c
index 588aa9a..bcec3f2 100644
--- a/gthumb/gth-folder-tree.c
+++ b/gthumb/gth-folder-tree.c
@@ -139,6 +139,7 @@ gth_folder_tree_finalize (GObject *object)
                _g_object_list_unref (folder_tree->priv->monitor.sources);
                if (folder_tree->priv->root != NULL)
                        g_object_unref (folder_tree->priv->root);
+               g_object_unref (folder_tree->priv->tree_store);
 
                g_free (folder_tree->priv);
                folder_tree->priv = NULL;
@@ -418,7 +419,7 @@ get_monitor_file_source_for_file (GthFolderTree *folder_tree,
 
                if (gth_file_source_supports_scheme (file_source, uri)) {
                        g_free (uri);
-                       return file_source;
+                       return g_object_ref (file_source);
                }
        }
 
@@ -439,6 +440,8 @@ _gth_folder_tree_remove_from_monitor (GthFolderTree *folder_tree,
                return;
 
        gth_file_source_monitor_directory (file_source, file, FALSE);
+
+       g_object_unref (file_source);
 }
 
 
@@ -468,12 +471,13 @@ _gth_folder_tree_add_to_monitor (GthFolderTree *folder_tree,
                file_source = gth_main_get_file_source (file);
                if (file_source == NULL)
                        return;
-
-               folder_tree->priv->monitor.sources = g_list_prepend (folder_tree->priv->monitor.sources, 
file_source);
+               folder_tree->priv->monitor.sources = g_list_prepend (folder_tree->priv->monitor.sources, 
g_object_ref (file_source));
        }
 
        gth_file_source_monitor_directory (file_source, file, TRUE);
        g_hash_table_add (folder_tree->priv->monitor.locations, g_file_dup (file));
+
+       g_object_unref (file_source);
 }
 
 
diff --git a/gthumb/gth-menu-manager.c b/gthumb/gth-menu-manager.c
index f14ce96..1a1ea67 100644
--- a/gthumb/gth-menu-manager.c
+++ b/gthumb/gth-menu-manager.c
@@ -167,7 +167,7 @@ create_menu_item (const char *label,
 {
        GMenuItem *item;
 
-       item = g_menu_item_new (label,detailed_action);
+       item = g_menu_item_new (label, detailed_action);
        g_menu_item_set_attribute (item, _G_MENU_ATTRIBUTE_DETAILED_ACTION, "s", detailed_action, NULL);
        if (accel != NULL)
                g_menu_item_set_attribute (item, "accel", "s", accel, NULL);
@@ -205,6 +205,8 @@ gth_menu_manager_append_entries (GthMenuManager     *menu_manager,
                g_menu_append_item (menu_manager->priv->menu, item);
 
                items = g_list_prepend (items, g_strdup (entry->detailed_action));
+
+               g_object_unref (item);
        }
 
        items = g_list_reverse (items);
@@ -302,4 +304,6 @@ gth_menu_manager_append_entry (GthMenuManager       *menu_manager,
        items = g_hash_table_lookup (menu_manager->priv->items, GINT_TO_POINTER (merge_id));
        items = g_list_append (items, g_strdup (detailed_action));
        g_hash_table_insert (menu_manager->priv->items, GINT_TO_POINTER (merge_id), items);
+
+       g_object_unref (item);
 }
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index 57221f2..3b86ee1 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -756,10 +756,11 @@ gth_window_change_action_state (GthWindow  *window,
        g_return_if_fail (action != NULL);
 
        old_state = g_action_get_state (action);
-       new_state = g_variant_new_boolean (value);
+       new_state = g_variant_ref_sink (g_variant_new_boolean (value));
        if ((old_state == NULL) || ! g_variant_equal (old_state, new_state))
                g_action_change_state (action, new_state);
 
        if (old_state != NULL)
                g_variant_unref (old_state);
+       g_variant_unref (new_state);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]