Commit 72c3f05d authored by Paolo Bacchilega's avatar Paolo Bacchilega

fixed a good amount of memory leaks

parent b51f6d66
......@@ -138,8 +138,10 @@ update_system_bookmark_list_from_content (GthBrowser *browser,
line = g_strsplit (lines[i], " ", 2);
uri = line[0];
if (uri == NULL)
if (uri == NULL) {
g_strfreev (line);
continue;
}
file = g_file_new_for_uri (uri);
icon = _g_file_get_icon (file);
......@@ -159,7 +161,7 @@ update_system_bookmark_list_from_content (GthBrowser *browser,
-1);
g_free (name);
g_object_unref (icon);
_g_object_unref (icon);
g_object_unref (file);
g_strfreev (line);
}
......
......@@ -245,6 +245,7 @@ _cairo_image_surface_create_from_png (GthFileData *file_data,
if (cairo_surface_status (cairo_png_data->surface) == CAIRO_STATUS_SUCCESS)
gth_image_set_cairo_surface (image, cairo_png_data->surface);
g_free (row_pointers);
_cairo_png_data_destroy (cairo_png_data);
return image;
......
......@@ -642,6 +642,8 @@ get_display_name (GFile *file,
}
}
g_free (basename);
return g_string_free (display_name, FALSE);
}
......@@ -675,6 +677,8 @@ get_edit_name (GFile *file,
g_string_append (display_name, name);
}
g_free (basename);
return g_string_free (display_name, FALSE);
}
......@@ -695,6 +699,8 @@ update_standard_attributes (GFile *file,
sort_order_s = gth_datetime_strftime (date_time, "%Y%m%d");
sort_order = atoi (sort_order_s);
g_file_info_set_sort_order (info, sort_order);
g_free (sort_order_s);
}
else if (g_file_info_get_attribute_boolean (info, "gthumb::no-child"))
g_file_info_set_sort_order (info, 99999999);
......@@ -822,6 +828,7 @@ gth_catalog_file_to_gio_file (GFile *file)
full_uri = g_strconcat (base_uri, part ? "/" : NULL, part, NULL);
gio_file = g_file_new_for_uri (full_uri);
g_free (full_uri);
g_free (base_uri);
g_object_unref (base);
}
......@@ -1158,7 +1165,8 @@ gth_catalog_save (GthCatalog *catalog)
gio_file = gth_catalog_file_to_gio_file (file);
gio_parent = g_file_get_parent (gio_file);
g_file_make_directory_with_parents (gio_parent, NULL, NULL);
if (gio_parent != NULL)
g_file_make_directory_with_parents (gio_parent, NULL, NULL);
data = gth_catalog_to_data (catalog, &size);
if (! g_write_file (gio_file,
FALSE,
......@@ -1198,6 +1206,6 @@ gth_catalog_save (GthCatalog *catalog)
}
g_free (data);
g_object_unref (gio_parent);
_g_object_unref (gio_parent);
g_object_unref (gio_file);
}
......@@ -71,14 +71,16 @@ update_file_info (GthFileSource *file_source,
GFile *catalog_file,
GFileInfo *info)
{
char *uri;
char *uri;
GIcon *icon = NULL;
uri = g_file_get_uri (catalog_file);
if (g_str_has_suffix (uri, ".gqv") || g_str_has_suffix (uri, ".catalog")) {
g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
g_file_info_set_content_type (info, "gthumb/catalog");
g_file_info_set_icon (info, g_themed_icon_new ("file-catalog"));
icon = g_themed_icon_new ("file-catalog");
g_file_info_set_icon (info, icon);
g_file_info_set_sort_order (info, 1);
g_file_info_set_attribute_boolean (info, "gthumb::no-child", TRUE);
gth_catalog_update_standard_attributes (catalog_file, info);
......@@ -86,7 +88,8 @@ update_file_info (GthFileSource *file_source,
else if (g_str_has_suffix (uri, ".search")) {
g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
g_file_info_set_content_type (info, "gthumb/search");
g_file_info_set_icon (info, g_themed_icon_new ("file-search"));
icon = g_themed_icon_new ("file-search");
g_file_info_set_icon (info, icon);
g_file_info_set_sort_order (info, 1);
g_file_info_set_attribute_boolean (info, "gthumb::no-child", TRUE);
gth_catalog_update_standard_attributes (catalog_file, info);
......@@ -94,12 +97,14 @@ update_file_info (GthFileSource *file_source,
else {
g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
g_file_info_set_content_type (info, "gthumb/library");
g_file_info_set_icon (info, g_themed_icon_new ("file-library"));
icon = g_themed_icon_new ("file-library");
g_file_info_set_icon (info, icon);
g_file_info_set_sort_order (info, 0);
g_file_info_set_attribute_boolean (info, "gthumb::no-child", FALSE);
gth_catalog_update_standard_attributes (catalog_file, info);
}
_g_object_unref (icon);
g_free (uri);
}
......
......@@ -317,6 +317,7 @@ gth_comment_new_for_file (GFile *file,
comment = NULL;
}
g_object_unref (doc);
g_free (buffer);
g_free (zipped_buffer);
......
......@@ -392,7 +392,6 @@ set_attribute_from_metadata (GFileInfo *info,
const char *attribute,
GObject *metadata)
{
char *key;
char *description;
char *formatted_value;
char *raw_value;
......@@ -402,7 +401,6 @@ set_attribute_from_metadata (GFileInfo *info,
return;
g_object_get (metadata,
"id", &key,
"description", &description,
"formatted", &formatted_value,
"raw", &raw_value,
......@@ -416,6 +414,11 @@ set_attribute_from_metadata (GFileInfo *info,
raw_value,
NULL,
type_name);
g_free (description);
g_free (formatted_value);
g_free (raw_value);
g_free (type_name);
}
......
......@@ -1105,7 +1105,7 @@ _gth_browser_update_open_menu (GthBrowser *browser,
gtk_widget_show (openwith_item);
g_hash_table_destroy (used_apps);
g_list_free (appinfo_list);
_g_object_list_unref (appinfo_list);
_g_object_list_unref (file_list);
_gtk_tree_path_list_free (items);
}
......
......@@ -228,12 +228,20 @@ gth_selections_manager_update_file_info (GFile *file,
/* icon */
if (n_selection > 0) {
GIcon *icon;
name = g_strdup_printf ("selection%d", n_selection);
g_file_info_set_icon (info, g_themed_icon_new (name));
icon = g_themed_icon_new (name);
g_file_info_set_icon (info, icon);
g_object_unref (icon);
g_free (name);
}
else
g_file_info_set_icon (info, g_themed_icon_new ("selection"));
else {
GIcon *icon = g_themed_icon_new ("selection");
g_file_info_set_icon (info, icon);
g_object_unref (icon);
}
/* display name */
......
......@@ -201,9 +201,10 @@ for_each_child_data_free (ForEachChildData *fec)
return;
g_object_unref (fec->base_directory);
if (fec->already_visited)
if (fec->already_visited != NULL)
g_hash_table_destroy (fec->already_visited);
clear_child_data (&(fec->current));
g_free (fec->attributes);
if (fec->to_visit != NULL) {
g_list_foreach (fec->to_visit, (GFunc) child_data_free, NULL);
g_list_free (fec->to_visit);
......
......@@ -1923,8 +1923,10 @@ _g_file_get_display_name (GFile *file)
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (file_info != NULL)
if (file_info != NULL) {
name = g_strdup (g_file_info_get_attribute_string (file_info, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME));
g_object_unref (file_info);
}
else
name = g_file_get_parse_name (file);
......@@ -2073,8 +2075,10 @@ _g_file_get_icon (GFile *file)
G_FILE_QUERY_INFO_NONE,
NULL,
NULL);
if (file_info != NULL)
icon = (GIcon*) g_file_info_get_attribute_object (file_info, G_FILE_ATTRIBUTE_STANDARD_ICON);
if (file_info != NULL) {
icon = (GIcon*) g_object_ref (g_file_info_get_attribute_object (file_info, G_FILE_ATTRIBUTE_STANDARD_ICON));
g_object_unref (file_info);
}
if (icon == NULL)
icon = g_themed_icon_new ("file");
......
......@@ -1573,7 +1573,7 @@ read_png_options (const char *thumbnail_filename)
f = fopen (thumbnail_filename, "r");
if (f == NULL) {
png_destroy_read_struct (&png_ptr, NULL, NULL);
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return options;
}
......
......@@ -3330,6 +3330,7 @@ pref_general_filter_changed (GSettings *settings,
filter = _gth_browser_get_file_filter (browser);
gth_file_list_set_filter (GTH_FILE_LIST (browser->priv->file_list), filter);
gth_file_list_set_filter (GTH_FILE_LIST (browser->priv->thumbnail_list), filter);
g_object_unref (filter);
}
......@@ -4033,6 +4034,7 @@ gth_browser_init (GthBrowser *browser)
GtkWidget *menubar;
GtkOrientation viewer_thumbnails_orientation;
char *general_filter;
char *sort_type;
char *caption;
int i;
......@@ -4410,8 +4412,9 @@ gth_browser_init (GthBrowser *browser)
/* the file list */
browser->priv->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_TYPE_NORMAL, TRUE);
sort_type = g_settings_get_string (browser->priv->browser_settings, PREF_BROWSER_SORT_TYPE);
gth_browser_set_sort_order (browser,
gth_main_get_sort_type (g_settings_get_string (browser->priv->browser_settings, PREF_BROWSER_SORT_TYPE)),
gth_main_get_sort_type (sort_type),
g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_SORT_INVERSE));
gth_browser_enable_thumbnails (browser, g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_SHOW_THUMBNAILS));
gth_file_list_set_thumb_size (GTH_FILE_LIST (browser->priv->file_list),
......@@ -4420,6 +4423,7 @@ gth_browser_init (GthBrowser *browser)
gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->file_list), caption);
g_free (caption);
g_free (sort_type);
gtk_widget_show (browser->priv->file_list);
gtk_box_pack_start (GTK_BOX (vbox), browser->priv->file_list, TRUE, TRUE, 0);
......
......@@ -452,8 +452,11 @@ gth_extension_description_load_from_file (GthExtensionDescription *desc,
key_file = g_key_file_new ();
file_path = g_file_get_path (file);
if (! g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_NONE, NULL))
if (! g_key_file_load_from_file (key_file, file_path, G_KEY_FILE_NONE, NULL)) {
g_free (file_path);
g_key_file_free (key_file);
return FALSE;
}
basename = g_file_get_basename (file);
desc->id = _g_uri_remove_extension (basename);
......@@ -849,6 +852,7 @@ gth_extension_manager_order_extensions (GthExtensionManager *manager,
ordered_by_dependency = _g_list_prepend_link (ordered_by_dependency, link);
}
}
g_list_free (dependencies);
/* prepend the extension to the ordered list */
extension_list = g_list_remove_link (extension_list, scan);
......
......@@ -548,6 +548,8 @@ gth_file_data_list_get_common_info (GList *file_data_list,
if (first_value == NULL)
g_file_info_remove_attribute (info, attribute);
g_free (first_value);
}
g_strfreev (attributes_v);
......
......@@ -1436,6 +1436,7 @@ thumbnail_job_ready_cb (GObject *source_object,
if ((! success && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|| file_list->priv->cancelling)
{
_g_object_unref (pixbuf);
thumbnail_job_free (job);
return;
}
......
......@@ -144,11 +144,11 @@ _gth_file_row_copy (GthFileRow *row)
}
G_GNUC_UNUSED
static void
static GthFileRow *
_gth_file_row_ref (GthFileRow *row)
{
row->ref_count++;
return row;
}
......@@ -169,6 +169,7 @@ _gth_file_row_unref (GthFileRow *row)
static void
_gth_file_store_clear_queue (GthFileStore *file_store)
{
g_list_foreach (file_store->priv->queue, (GFunc) _gth_file_row_unref, NULL);
g_list_free (file_store->priv->queue);
file_store->priv->queue = NULL;
}
......@@ -803,7 +804,7 @@ g_print ("UPDATE VISIBILITY\n");
for (i = 0; i < position; i++)
all_rows[j++] = _gth_file_row_copy (file_store->priv->all_rows[i]);
for (scan = add_queue; scan; scan = scan->next)
all_rows[j++] = (GthFileRow *) scan->data;
all_rows[j++] = _gth_file_row_ref ((GthFileRow *) scan->data);
for (i = position; i < file_store->priv->tot_rows; i++)
all_rows[j++] = _gth_file_row_copy (file_store->priv->all_rows[i]);
......@@ -1565,7 +1566,7 @@ gth_file_store_queue_remove (GthFileStore *file_store,
row = (GthFileRow*) iter->user_data;
file_store->priv->queue = g_list_prepend (file_store->priv->queue, file_store->priv->all_rows[row->abs_pos]);
file_store->priv->queue = g_list_prepend (file_store->priv->queue, _gth_file_row_ref (file_store->priv->all_rows[row->abs_pos]));
}
......
......@@ -53,6 +53,8 @@ gth_filter_file_new (void)
void
gth_filter_file_free (GthFilterFile *filters)
{
if (filters == NULL)
return;
_g_object_list_unref (filters->items);
g_free (filters);
}
......
......@@ -137,6 +137,8 @@ gth_filter_real_load_from_element (DomDomizable *base,
test = gth_test_chain_new (GTH_MATCH_TYPE_NONE, NULL);
dom_domizable_load_from_element (DOM_DOMIZABLE (test), node);
gth_filter_set_test (self, GTH_TEST_CHAIN (test));
g_object_unref (test);
}
else if (g_strcmp0 (node->tag_name, "limit") == 0) {
gth_filter_set_limit (self,
......
......@@ -204,17 +204,18 @@ load_pixbuf_thread (GSimpleAsyncResult *result,
error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("No suitable loader available for this file type"));
}
load_result = g_new0 (LoadResult, 1);
load_result->image = image;
load_result->original_width = original_width;
load_result->original_height = original_height;
if (error != NULL) {
_g_object_unref (image);
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
return;
}
else
g_simple_async_result_set_op_res_gpointer (result, load_result, (GDestroyNotify) load_result_unref);
load_result = g_new0 (LoadResult, 1);
load_result->image = image;
load_result->original_width = original_width;
load_result->original_height = original_height;
g_simple_async_result_set_op_res_gpointer (result, load_result, (GDestroyNotify) load_result_unref);
}
......
......@@ -169,6 +169,7 @@ gth_image_viewer_finalize (GObject *object)
}
g_list_foreach (self->priv->painters, (GFunc) painter_data_free, NULL);
_g_object_unref (self->priv->tool);
_g_clear_object (&self->priv->image);
_g_clear_object (&self->priv->animation);
......
......@@ -231,7 +231,7 @@ gth_image_get_pixbuf (GthImage *image)
break;
case GTH_IMAGE_FORMAT_GDK_PIXBUF:
result = g_object_ref (image->priv->data.pixbuf);
result = _g_object_ref (image->priv->data.pixbuf);
break;
case GTH_IMAGE_FORMAT_GDK_PIXBUF_ANIMATION:
......@@ -283,7 +283,8 @@ gth_image_get_pixbuf_animation (GthImage *image)
break;
case GTH_IMAGE_FORMAT_GDK_PIXBUF:
result = gdk_pixbuf_non_anim_new (image->priv->data.pixbuf);
if (image->priv->data.pixbuf != NULL)
result = gdk_pixbuf_non_anim_new (image->priv->data.pixbuf);
break;
case GTH_IMAGE_FORMAT_GDK_PIXBUF_ANIMATION:
......
......@@ -471,6 +471,8 @@ update_location_list (gpointer user_data)
g_object_unref (info);
}
_g_object_list_unref (list);
}
}
......
......@@ -143,10 +143,11 @@ gth_main_finalize (GObject *object)
if (gth_main->priv->bookmarks != NULL)
g_bookmark_file_free (gth_main->priv->bookmarks);
if (gth_main->priv->monitor != NULL)
g_object_unref (gth_main->priv->monitor);
if (gth_main->priv->extension_manager != NULL)
g_object_unref (gth_main->priv->extension_manager);
_g_object_unref (gth_main->priv->monitor);
_g_object_unref (gth_main->priv->extension_manager);
gth_filter_file_free (gth_main->priv->filters);
gth_tags_file_free (gth_main->priv->tags);
g_free (gth_main->priv);
gth_main->priv = NULL;
......@@ -777,7 +778,6 @@ gth_main_add_general_filter (GthTest *original_filter)
new_chain = gth_test_chain_new (GTH_MATCH_TYPE_ALL, NULL);
gth_test_chain_add_test (GTH_TEST_CHAIN (new_chain), test);
g_object_unref (test);
if (strncmp (gth_test_get_id (test), "file::type::", 12) != 0) {
GthTest *file_type_filter;
......@@ -789,6 +789,7 @@ gth_main_add_general_filter (GthTest *original_filter)
gth_filter_set_test (filter, GTH_TEST_CHAIN (new_chain));
g_object_unref (new_chain);
g_object_unref (test);
test = (GthTest*) filter;
}
else {
......@@ -1319,7 +1320,7 @@ attribute_list_reload_required (const char *old_attributes,
}
}
g_object_ref (provider);
g_object_unref (provider);
}
/*
......
......@@ -54,11 +54,29 @@ struct _GthMultipagePrivate {
G_DEFINE_TYPE (GthMultipage, gth_multipage, GTK_TYPE_BOX)
static void
gth_multipage_finalize (GObject *object)
{
GthMultipage *multipage;
multipage = GTH_MULTIPAGE (object);
g_list_free (multipage->priv->children);
G_OBJECT_CLASS (gth_multipage_parent_class)->finalize (object);
}
static void
gth_multipage_class_init (GthMultipageClass *klass)
{
GObjectClass *object_class;
g_type_class_add_private (klass, sizeof (GthMultipagePrivate));
object_class = (GObjectClass*) klass;
object_class->finalize = gth_multipage_finalize;
/* signals */
gth_multipage_signals[CHANGED] =
......
......@@ -53,6 +53,8 @@ gth_tags_file_new (void)
void
gth_tags_file_free (GthTagsFile *tags)
{
if (tags == NULL)
return;
_g_string_list_free (tags->items);
g_strfreev (tags->tags);
g_free (tags);
......
......@@ -64,6 +64,7 @@ gth_test_chain_finalize (GObject *object)
_g_object_list_unref (test->priv->tests);
if (test->priv->attributes != NULL)
g_string_free (test->priv->attributes, TRUE);
g_free (test->priv);
test->priv = NULL;
}
......
......@@ -81,6 +81,7 @@ gth_test_finalize (GObject *object)
self = GTH_TEST (object);
g_free (self->priv->id);
g_free (self->priv->attributes);
g_free (self->priv->display_name);
g_free (self->files);
......
......@@ -332,7 +332,9 @@ load_data_unref (LoadData *load_data)
{
g_object_unref (load_data->thumb_loader);
g_object_unref (load_data->file_data);
_g_object_unref (load_data->simple);
_g_object_unref (load_data->cancellable);
g_free (load_data->thumbnailer_tmpfile);
g_free (load_data);
}
......@@ -806,6 +808,7 @@ gth_thumb_loader_load (GthThumbLoader *self,
g_error_free (error);
g_free (uri);
g_object_unref (simple);
return;
}
......@@ -826,6 +829,7 @@ gth_thumb_loader_load (GthThumbLoader *self,
g_simple_async_result_complete_in_idle (simple);
g_error_free (error);
g_object_unref (simple);
return;
}
......
......@@ -213,6 +213,8 @@ update_view_from_data (GthTimeSelector *self)
text = gth_datetime_strftime (self->priv->date_time, "%X");
entry = gtk_bin_get_child (GTK_BIN (self->priv->time_combo_box));
gtk_entry_set_text (GTK_ENTRY (entry), text);
g_free (text);
}
else {
GtkWidget *entry;
......
......@@ -482,7 +482,7 @@ _g_icon_get_pixbuf (GIcon *icon,
pixbuf = NULL;
if (G_IS_THEMED_ICON (icon))
pixbuf = get_themed_icon_pixbuf (G_THEMED_ICON (icon), size, theme);
if (G_IS_FILE_ICON (icon))
else if (G_IS_FILE_ICON (icon))
pixbuf = get_file_icon_pixbuf (G_FILE_ICON (icon), size);
if (pixbuf == NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment