Fix T49139: Memory leak in UV image editor related to Undo (and possibly Waveform...
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 26 Aug 2016 10:54:49 +0000 (12:54 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 26 Aug 2016 10:54:49 +0000 (12:54 +0200)
Assigning NULL to scopes' data pointer in 'non-UI readfile' context was terribly wrong for sure,
if we'd really want to reset them here we should freed them first.

But we can rather just ignore them here, those are purely runtime data managed by image editor,
no need to touch them here.

source/blender/blenloader/intern/readfile.c

index ded60af4af25060a8ac7c243f1d0ca7bde3214db..7d65dbc2e17f2003df403bdea535c52ede063e70 100644 (file)
@@ -6697,10 +6697,13 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
                                         * since it gets initialized later */
                                        sima->iuser.scene = NULL;
                                        
-                                       sima->scopes.waveform_1 = NULL;
-                                       sima->scopes.waveform_2 = NULL;
-                                       sima->scopes.waveform_3 = NULL;
-                                       sima->scopes.vecscope = NULL;
+#if 0
+                                       /* Those are allocated and freed by space code, no need to handle them here. */
+                                       MEM_SAFE_FREE(sima->scopes.waveform_1);
+                                       MEM_SAFE_FREE(sima->scopes.waveform_2);
+                                       MEM_SAFE_FREE(sima->scopes.waveform_3);
+                                       MEM_SAFE_FREE(sima->scopes.vecscope);
+#endif
                                        sima->scopes.ok = 0;
                                        
                                        /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data