[nautilus] batch-rename: Fix memory leaks
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] batch-rename: Fix memory leaks
- Date: Wed, 5 Oct 2016 09:26:18 +0000 (UTC)
commit 1ebe0a852bfdd245888ba58d788a36716f778f72
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Thu Sep 29 22:05:58 2016 +0300
batch-rename: Fix memory leaks
Fix memory leaks for batch renaming.
https://bugzilla.gnome.org/show_bug.cgi?id=771490
src/nautilus-batch-rename-dialog.c | 7 ++++++-
src/nautilus-batch-rename-utilities.c | 15 +++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 170919f..6acccaa 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -405,6 +405,10 @@ split_entry_text (NautilusBatchRenameDialog *self,
{
result = g_list_prepend (result, normal_text);
}
+ else
+ {
+ g_string_free (normal_text, TRUE);
+ }
result = g_list_reverse (result);
@@ -868,6 +872,7 @@ select_nth_conflict (NautilusBatchRenameDialog *dialog)
display_text->str);
g_string_free (conflict_file_name, TRUE);
+ g_string_free (display_text, TRUE);
}
static void
@@ -1181,7 +1186,7 @@ check_conflict_for_files (NautilusBatchRenameDialog *dialog,
if (!have_conflict)
{
tag_present = g_hash_table_lookup (names_conflicts_table, new_name->str) != NULL;
- same_parent_directory = g_strcmp0 (nautilus_file_get_parent_uri (file), current_directory) == 0;
+ same_parent_directory = g_strcmp0 (parent_uri, current_directory) == 0;
if (tag_present && same_parent_directory)
{
diff --git a/src/nautilus-batch-rename-utilities.c b/src/nautilus-batch-rename-utilities.c
index 09bea45..970a131 100644
--- a/src/nautilus-batch-rename-utilities.c
+++ b/src/nautilus-batch-rename-utilities.c
@@ -237,7 +237,6 @@ batch_rename_format (NautilusFile *file,
g_autofree gchar *extension = NULL;
gint i;
gchar *metadata;
- gchar *base_name;
file_name = nautilus_file_get_display_name (file);
extension = nautilus_file_get_extension (file);
@@ -314,6 +313,8 @@ batch_rename_format (NautilusFile *file,
{
case ORIGINAL_FILE_NAME:
{
+ g_autofree gchar *base_name = NULL;
+
base_name = eel_filename_strip_extension (file_name);
new_name = g_string_append (new_name, base_name);
@@ -375,7 +376,6 @@ batch_rename_dialog_get_new_names_list (NautilusBatchRenameDialogMode mode,
result = NULL;
count = 1;
- file_name = g_string_new ("");
for (l = selection; l != NULL; l = l->next)
{
@@ -421,12 +421,14 @@ file_name_conflicts_with_results (GList *selection,
GList *l1;
GList *l2;
NautilusFile *selection_file;
- gchar *name1;
GString *new_name;
gchar *selection_parent_uri;
for (l1 = selection, l2 = new_names; l1 != NULL && l2 != NULL; l1 = l1->next, l2 = l2->next)
{
+ g_autofree gchar *name1 = NULL;
+ g_autofree gchar *selection_parent_uri = NULL;
+
selection_file = NAUTILUS_FILE (l1->data);
name1 = nautilus_file_get_name (selection_file);
@@ -448,8 +450,6 @@ file_name_conflicts_with_results (GList *selection,
* conflict */
return TRUE;
}
-
- g_free (selection_parent_uri);
}
/* the case this function searched for doesn't exist, so the file
@@ -899,6 +899,7 @@ check_metadata_for_selection (NautilusBatchRenameDialog *dialog,
FileMetadata *file_metadata;
GList *selection_metadata;
guint i;
+ g_autofree gchar *parent_uri = NULL;
error = NULL;
selection_metadata = NULL;
@@ -921,9 +922,11 @@ check_metadata_for_selection (NautilusBatchRenameDialog *dialog,
"nmm:albumTitle(nmm:musicAlbum(?file)) "
"WHERE { ?file a nfo:FileDataObject. ");
+ parent_uri = nautilus_file_get_parent_uri (NAUTILUS_FILE (selection->data));
+
g_string_append_printf (query,
"FILTER(tracker:uri-is-parent('%s', nie:url(?file))) ",
- nautilus_file_get_parent_uri (NAUTILUS_FILE (selection->data)));
+ parent_uri);
for (l = selection; l != NULL; l = l->next)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]