[Bf-blender-cvs] [e6b7905fe65] master: Fix memory leak when loading previous preferences from splash screen

Julian Eisel noreply at git.blender.org
Sun Feb 21 17:32:46 CET 2021


Commit: e6b7905fe6510a31893ca14383fd2cafafbc8e2f
Author: Julian Eisel
Date:   Sun Feb 21 17:29:52 2021 +0100
Branches: master
https://developer.blender.org/rBe6b7905fe6510a31893ca14383fd2cafafbc8e2f

Fix memory leak when loading previous preferences from splash screen

When opening a Blender version for which there are no preferences, the splash
shows a button like "Load 2.92 Settings". Using this could cause a memory leak
of the storage for recently opened files.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 090c28a81a6..8bea2203abe 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -140,6 +140,7 @@
 
 static RecentFile *wm_file_history_find(const char *filepath);
 static void wm_history_file_free(RecentFile *recent);
+static void wm_history_files_free(void);
 static void wm_history_file_update(void);
 static void wm_history_file_write(void);
 
@@ -1188,7 +1189,7 @@ void wm_history_file_read(void)
 
   lines = BLI_file_read_as_lines(name);
 
-  BLI_listbase_clear(&G.recent_files);
+  wm_history_files_free();
 
   /* read list of recent opened files from recent-files.txt to memory */
   for (l = lines, num = 0; l && (num < U.recent_files); l = l->next) {
@@ -1219,6 +1220,13 @@ static void wm_history_file_free(RecentFile *recent)
   BLI_freelinkN(&G.recent_files, recent);
 }
 
+static void wm_history_files_free(void)
+{
+  LISTBASE_FOREACH_MUTABLE (RecentFile *, recent, &G.recent_files) {
+    wm_history_file_free(recent);
+  }
+}
+
 static RecentFile *wm_file_history_find(const char *filepath)
 {
   return BLI_findstring_ptr(&G.recent_files, filepath, offsetof(RecentFile, filepath));



More information about the Bf-blender-cvs mailing list