summaryrefslogtreecommitdiff
path: root/thunar
diff options
context:
space:
mode:
authorSergios - Anestis Kefalidis <megistios@gmail.com>2022-02-25 22:32:58 +0000
committerAlexander Schwinn <alexxcons@xfce.org>2022-02-25 22:32:58 +0000
commitf8bb47020a59659842a725ff34fbbb5a0320186b (patch)
tree610899f7152bac00e39c6f83f89f848a19a321d0 /thunar
parent7bab9061f9158a160ca20cd516fb2f7dfc6d6d84 (diff)
downloadthunar-f8bb47020a59659842a725ff34fbbb5a0320186b.tar.gz
Fix of various memory leaks
Diffstat (limited to 'thunar')
-rw-r--r--thunar/thunar-application.c14
-rw-r--r--thunar/thunar-device.c6
-rw-r--r--thunar/thunar-launcher.c8
-rw-r--r--thunar/thunar-list-model.c9
-rw-r--r--thunar/thunar-properties-dialog.c1
-rw-r--r--thunar/thunar-util.c4
-rw-r--r--thunar/thunar-window.c10
7 files changed, 42 insertions, 10 deletions
diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index f2fa0b8e..578047c3 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -903,6 +903,7 @@ thunar_application_launch_finished (ThunarJob *job,
/* Unref all containing_folders (refs obtained by g_file_get_parent in thunar_g_file_list_get_parents ) */
g_object_unref (lp->data);
}
+ g_list_free (containing_folders);
}
@@ -1414,15 +1415,22 @@ thunar_application_open_window (ThunarApplication *application,
list = thunar_application_get_windows (application);
if (list != NULL)
{
+ GList *lp = list;
+ GtkWidget *data;
+
/* this will be the topmost Window */
list = g_list_last (list);
+ data = list->data;
if (directory != NULL)
- thunar_window_notebook_add_new_tab (THUNAR_WINDOW (list->data), directory, THUNAR_NEW_TAB_BEHAVIOR_SWITCH);
+ thunar_window_notebook_add_new_tab (THUNAR_WINDOW (data), directory, THUNAR_NEW_TAB_BEHAVIOR_SWITCH);
/* bring the window to front */
- gtk_window_present (list->data);
- return list->data;
+ gtk_window_present (GTK_WINDOW (data));
+
+ g_list_free (lp);
+
+ return data;
}
}
diff --git a/thunar/thunar-device.c b/thunar/thunar-device.c
index 6e6d9124..e6c50480 100644
--- a/thunar/thunar-device.c
+++ b/thunar/thunar-device.c
@@ -681,6 +681,7 @@ thunar_device_compare_by_name (const ThunarDevice *device1,
{
gchar* name1;
gchar* name2;
+ gint result;
_thunar_return_val_if_fail (THUNAR_IS_DEVICE (device1), 0);
_thunar_return_val_if_fail (THUNAR_IS_DEVICE (device2), 0);
@@ -692,11 +693,12 @@ thunar_device_compare_by_name (const ThunarDevice *device1,
name1 = thunar_device_get_name (device1);
name2 = thunar_device_get_name (device2);
- /* code which compares device names */
- return g_strcmp0 (name1, name2);
+ result = g_strcmp0 (name1, name2);
g_free (name1);
g_free (name2);
+
+ return result;
}
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 4fec1042..c179e5cc 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -1147,7 +1147,9 @@ thunar_launcher_poke_files_finish (ThunarBrowser *browser,
{
/* add opened file to `recent:///` */
GFile *gfile = thunar_file_get_file (target_file);
- gtk_recent_manager_add_item (gtk_recent_manager_get_default(), g_file_get_uri (gfile));
+ gchar *uri = g_file_get_uri (gfile);
+ gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri);
+ g_free (uri);
/* add the resolved file to the list of file to be opened/executed later */
poke_data->files_poked = g_list_prepend (poke_data->files_poked,g_object_ref (target_file));
@@ -2649,12 +2651,14 @@ thunar_launcher_action_create_document (ThunarLauncher *launcher,
if (template_file != NULL)
{
+ gchar *basename = g_file_get_basename (thunar_file_get_file (template_file));
/* generate a title for the create dialog */
title = g_strdup_printf (_("Create Document from template \"%s\""),
thunar_file_get_display_name (template_file));
/* ask the user to enter a name for the new document */
- generated_name = thunar_util_next_new_file_name (launcher->current_directory, g_file_get_basename (thunar_file_get_file (template_file)), THUNAR_NEXT_FILE_NAME_MODE_NEW);
+ generated_name = thunar_util_next_new_file_name (launcher->current_directory, basename, THUNAR_NEXT_FILE_NAME_MODE_NEW);
+ g_free (basename);
name = thunar_dialogs_show_create (launcher->widget,
thunar_file_get_content_type (THUNAR_FILE (template_file)),
generated_name,
diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c
index 3f6b8bb6..916ce2e0 100644
--- a/thunar/thunar-list-model.c
+++ b/thunar/thunar-list-model.c
@@ -526,6 +526,8 @@ thunar_list_model_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (G_OBJECT (store->file_monitor), thunar_list_model_file_changed, store);
g_object_unref (G_OBJECT (store->file_monitor));
+ g_free (store->date_custom_style);
+
(*G_OBJECT_CLASS (thunar_list_model_parent_class)->finalize) (object);
}
@@ -2032,6 +2034,7 @@ thunar_list_model_set_date_custom_style (ThunarListModel *store,
if (g_strcmp0 (store->date_custom_style, date_custom_style) != 0)
{
/* apply the new setting */
+ g_free (store->date_custom_style);
store->date_custom_style = g_strdup (date_custom_style);
/* notify listeners */
@@ -2999,7 +3002,11 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store,
else if (G_UNLIKELY (thunar_file_get_kind (file) == G_FILE_TYPE_MOUNTABLE))
filetype_string = g_strdup ("mountable");
else
- filetype_string = g_strdup_printf (_("%s"), g_content_type_get_description (content_type));
+ {
+ gchar *description = g_content_type_get_description (content_type);
+ filetype_string = g_strdup_printf (_("%s"), description);
+ g_free (description);
+ }
}
if (show_display_name == TRUE)
diff --git a/thunar/thunar-properties-dialog.c b/thunar/thunar-properties-dialog.c
index d9bbb1f7..ab8576d8 100644
--- a/thunar/thunar-properties-dialog.c
+++ b/thunar/thunar-properties-dialog.c
@@ -1263,6 +1263,7 @@ thunar_properties_dialog_update_single (ThunarPropertiesDialog *dialog)
/* cleanup */
g_object_unref (G_OBJECT (icon_factory));
+ g_free (date_custom_style);
}
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index c95b36b8..a17cb53f 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -715,13 +715,15 @@ thunar_util_next_new_file_name (ThunarFile *dir,
for (GList *files = thunar_folder_get_files (folder); files != NULL; files = files->next)
{
ThunarFile *file = files->data;
- const gchar *name = g_file_get_basename (thunar_file_get_file (file));
+ gchar *name = g_file_get_basename (thunar_file_get_file (file));
if (g_strcmp0 (new_name, name) == 0)
{
found_duplicate = TRUE;
+ g_free (name);
break;
}
+ g_free (name);
}
if (!found_duplicate)
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 9a7ce952..01a40b7e 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1045,7 +1045,7 @@ thunar_window_open_files_in_location (ThunarWindow *window,
{
ThunarApplication *application;
GHashTable *restore_show_table; /* <string, GList<GFile*>> */
- const gchar *original_uri;
+ gchar *original_uri;
GFile *original_dir_file;
gchar *original_dir_path;
@@ -1070,6 +1070,7 @@ thunar_window_open_files_in_location (ThunarWindow *window,
list = g_list_append (list, g_file_new_for_commandline_arg (original_uri));
}
+ g_free (original_uri);
g_object_unref (original_dir_file);
}
/* open tabs and show files */
@@ -1440,6 +1441,10 @@ thunar_window_finalize (GObject *object)
{
ThunarWindow *window = THUNAR_WINDOW (object);
+ thunar_window_free_bookmarks (window);
+ g_list_free_full (window->thunarx_preferences_providers, g_object_unref);
+ g_free (window->search_query);
+
/* disconnect from the volume monitor */
g_signal_handlers_disconnect_matched (window->device_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
g_object_unref (window->device_monitor);
@@ -2866,6 +2871,7 @@ thunar_window_free_bookmarks (ThunarWindow *window)
g_free (bookmark->name);
g_slice_free (ThunarBookmark, lp->data);
}
+ g_list_free (window->bookmarks);
window->bookmarks = NULL;
}
@@ -3023,6 +3029,8 @@ thunar_window_action_cancel_search (ThunarWindow *window)
thunar_standard_view_set_searching (THUNAR_STANDARD_VIEW (window->view), NULL);
thunar_launcher_set_searching (window->launcher, FALSE);
gtk_widget_hide (window->catfish_search_button);
+
+ g_free (window->search_query);
window->search_query = NULL;
if (THUNAR_IS_DETAILS_VIEW (window->view))