Commit: 0fc05c1c03ccbc7b4cadd63281799c2b4b2b96ac
Author: Bastien Montagne
Date:   Sun Jul 13 15:16:01 2014 +0200
https://developer.blender.org/rB0fc05c1c03ccbc7b4cadd63281799c2b4b2b96ac

Followup to rB320b7a59c3eed: also handle background image ID refcount when 
duplicating/freeing View3D.

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

M       source/blender/editors/space_view3d/space_view3d.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c 
b/source/blender/editors/space_view3d/space_view3d.c
index 7a4634b..77a5ac1 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -44,6 +44,7 @@
 
 #include "BKE_context.h"
 #include "BKE_icons.h"
+#include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
 #include "BKE_scene.h"
@@ -389,7 +390,16 @@ static SpaceLink *view3d_new(const bContext *C)
 static void view3d_free(SpaceLink *sl)
 {
        View3D *vd = (View3D *) sl;
+       BGpic *bgpic;
 
+       for (bgpic = vd->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+               if (bgpic->source == V3D_BGPIC_IMAGE) {
+                       id_us_min((ID *)bgpic->ima);
+               }
+               else if (bgpic->source == V3D_BGPIC_MOVIE) {
+                       id_us_min((ID *)bgpic->clip);
+               }
+       }
        BLI_freelistN(&vd->bgpicbase);
 
        if (vd->localvd) MEM_freeN(vd->localvd);
@@ -416,6 +426,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
 {
        View3D *v3do = (View3D *)sl;
        View3D *v3dn = MEM_dupallocN(sl);
+       BGpic *bgpic;
        
        /* clear or remove stuff from old */
        
@@ -433,8 +444,16 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
        /* copy or clear inside new stuff */
 
        v3dn->defmaterial = NULL;
-       
+
        BLI_duplicatelist(&v3dn->bgpicbase, &v3do->bgpicbase);
+       for (bgpic = v3dn->bgpicbase.first; bgpic; bgpic = bgpic->next) {
+               if (bgpic->source == V3D_BGPIC_IMAGE) {
+                       id_us_plus((ID *)bgpic->ima);
+               }
+               else if (bgpic->source == V3D_BGPIC_MOVIE) {
+                       id_us_plus((ID *)bgpic->clip);
+               }
+       }
 
        v3dn->properties_storage = NULL;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to