[nautilus] nautilus-directory.c: Fix a memory leak.



commit 48d626cea93230561556cd84dad2d9d78939b1dc
Author: Michael Webster <miketwebster gmail com>
Date:   Sun May 16 20:24:16 2021 -0400

    nautilus-directory.c: Fix a memory leak.
    
    When creating a new file using a template, it's possible for is_added
    to be FALSE, so make sure the file is unref'd regardless.
    
    This actually resolves an issue in caja and nemo which is caused by
    files created in this manner not being finalized when no longer in use.
    I can reproduce the issue with nautilus, but this *does not* fix it,
    so I think that there may be an additional leak somewhere else (maybe
    not related to template-created files).
    
    To reproduce:
    - Create an svg file and save in ~/Templates.
    - Right-click, Create document-> svg file, name it whatever.
    - Navigate out of the folder.
    - Modify the file in a visible manner.
    - Re-enter the folder, note that it never finishes loading.
    
    Original report:
    https://github.com/linuxmint/nemo/issues/2736

 src/nautilus-directory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/nautilus-directory.c b/src/nautilus-directory.c
index 527b6bf93..f54ad5aac 100644
--- a/src/nautilus-directory.c
+++ b/src/nautilus-directory.c
@@ -1289,7 +1289,6 @@ nautilus_directory_notify_files_added (GList *files)
              * If it was renamed this could be ignored, but
              * queue a change just in case */
             nautilus_file_changed (file);
-            nautilus_file_unref (file);
         }
         else
         {
@@ -1297,6 +1296,7 @@ nautilus_directory_notify_files_added (GList *files)
                                      directory,
                                      g_object_ref (location));
         }
+        nautilus_file_unref (file);
         nautilus_directory_unref (directory);
     }
 


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