cancelling bake wasn't freeing the bake mask.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 22 Apr 2011 16:47:17 +0000 (16:47 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 22 Apr 2011 16:47:17 +0000 (16:47 +0000)
source/blender/editors/object/object_bake.c

index b4a358150e820a55362b587612813f929689077a..b513bab3924f4edac875f9f2635201c014d477c0 100644 (file)
@@ -189,9 +189,18 @@ static void finish_bake_internal(BakeRender *bkr)
                for(ima= G.main->image.first; ima; ima= ima->id.next) {
                        if(ima->ok==IMA_OK_LOADED) {
                                ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
-                               if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
-                                       GPU_free_image(ima);
-                                       imb_freemipmapImBuf(ibuf);
+                               if(ibuf) {
+                                       if(ibuf->userflags & IB_BITMAPDIRTY) {
+                                               GPU_free_image(ima);
+                                               imb_freemipmapImBuf(ibuf);
+                                       }
+
+                                       /* freed when baking is done, but if its canceled we need to free here */
+                                       if (ibuf->userdata) {
+                                               printf("freed\n");
+                                               MEM_freeN(ibuf->userdata);
+                                               ibuf->userdata= NULL;
+                                       }
                                }
                        }
                }