[Bf-blender-cvs] [6ccd672feed] temp-lanpr-review: Fix crash on disabling collection LANPR

Julian Eisel noreply at git.blender.org
Wed Nov 27 17:12:04 CET 2019


Commit: 6ccd672feedbf8b93bf10cdc4e00f200c0615fa6
Author: Julian Eisel
Date:   Wed Nov 27 17:10:27 2019 +0100
Branches: temp-lanpr-review
https://developer.blender.org/rB6ccd672feedbf8b93bf10cdc4e00f200c0615fa6

Fix crash on disabling collection LANPR

Also:
* Avoid duplicated copy code (copy code performed already and wouldn't actually run)
* Cleanup freeing

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

M	source/blender/blenkernel/intern/collection.c

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index ec8e8bb1b3f..ed306dfa4df 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -127,10 +127,7 @@ void BKE_collection_free(Collection *collection)
   BKE_collection_object_cache_free(collection);
 
   /* Remove LANPR configurations */
-  if (collection->lanpr) {
-    MEM_freeN(collection->lanpr);
-    collection->lanpr = NULL;
-  }
+  MEM_SAFE_FREE(collection->lanpr);
 }
 
 /**
@@ -235,12 +232,8 @@ void BKE_collection_copy_data(Main *bmain,
   }
 
   /* Copy LANPR configurations */
-  if ((collection_src->lanpr != NULL) && (collection_dst->lanpr == NULL)) {
-    CollectionLANPR *lanpr = MEM_callocN(sizeof(CollectionLANPR), "Duplicated CollectionLANPR");
-    collection_dst->lanpr = lanpr;
-  }
-  if (collection_dst->lanpr != NULL) {
-    memcpy(collection_dst->lanpr, collection_src->lanpr, sizeof(CollectionLANPR));
+  if (collection_src->lanpr != NULL) {
+    collection_dst->lanpr = MEM_dupallocN(collection_src->lanpr);
   }
 }
 
@@ -381,13 +374,6 @@ Collection *BKE_collection_duplicate(Main *bmain,
 
   BKE_main_collection_sync(bmain);
 
-  /* Copy LANPR configurations */
-  if ((collection->lanpr != NULL) && (collection_new->lanpr == NULL)) {
-    CollectionLANPR *lanpr = MEM_callocN(sizeof(CollectionLANPR), "Duplicated CollectionLANPR");
-    collection_new->lanpr = lanpr;
-  }
-  memcpy(collection_new->lanpr, collection->lanpr, sizeof(CollectionLANPR));
-
   return collection_new;
 }



More information about the Bf-blender-cvs mailing list