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.
This commit is contained in:
parent
0c62906a41
commit
e6b7905fe6
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue