Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-02-21 19:29:52 +0300
committerJulian Eisel <julian@blender.org>2021-02-21 19:32:33 +0300
commite6b7905fe6510a31893ca14383fd2cafafbc8e2f (patch)
tree9fc99e72c2ee96581f1f39397ba27d20da616be4
parent0c62906a4145b242d5ed772209038f65d7b493a8 (diff)
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.
-rw-r--r--source/blender/windowmanager/intern/wm_files.c10
1 files changed, 9 insertions, 1 deletions
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));