Make Scene Master collection 'Private' ID data, like root nodetrees.

Same issue here as with root nodetrees, those are private ID data owned
by another ID, and not in Main DB. This requires special handling.

there are still quiet a few things to do here, like getting rid of
special code for master collection (regular ID copying should handle
that just as it already does for root nodetrees), cleanup in ID copying
code, etc.
This commit is contained in:
Bastien Montagne
2019-09-02 12:14:51 +02:00
parent 283d96de11
commit 64efbbca8e
4 changed files with 24 additions and 4 deletions

View File

@@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 281
#define BLENDER_SUBVERSION 4
#define BLENDER_SUBVERSION 5
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0

View File

@@ -338,8 +338,9 @@ Collection *BKE_collection_duplicate(Main *bmain,
const bool do_obdata)
{
/* It's not allowed to copy the master collection. */
BLI_assert((collection->id.flag & LIB_PRIVATE_DATA) == 0);
BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0);
if (collection->flag & COLLECTION_IS_MASTER) {
BLI_assert("!Master collection can't be duplicated");
return NULL;
}
@@ -368,6 +369,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
Collection *BKE_collection_copy_master(Main *bmain, Collection *collection, const int flag)
{
BLI_assert(collection->flag & COLLECTION_IS_MASTER);
BLI_assert(collection->id.flag & LIB_PRIVATE_DATA);
Collection *collection_dst = MEM_dupallocN(collection);
BKE_collection_copy_data(bmain, collection_dst, collection, flag);
@@ -499,6 +501,7 @@ Collection *BKE_collection_master_add()
/* Not an actual datablock, but owned by scene. */
Collection *master_collection = MEM_callocN(sizeof(Collection), "Master Collection");
STRNCPY(master_collection->id.name, "GRMaster Collection");
master_collection->id.flag |= LIB_PRIVATE_DATA;
master_collection->flag |= COLLECTION_IS_MASTER;
return master_collection;
}

View File

@@ -3704,12 +3704,23 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_MAIN_ID_END;
}
{
/* Versioning code until next subversion bump goes here. */
if (!MAIN_VERSION_ATLEAST(bmain, 281, 5)) {
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
if (br->ob_mode & OB_MODE_SCULPT && br->normal_radius_factor == 0.0f) {
br->normal_radius_factor = 0.5f;
}
}
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
/* Older files do not hqve a msater collection, which is then added through
* `BKE_collection_master_add()`, so everything is fine. */
if (scene->master_collection != NULL) {
scene->master_collection->id.flag |= LIB_PRIVATE_DATA;
}
}
}
{
/* Versioning code until next subversion bump goes here. */
}
}

View File

@@ -41,6 +41,7 @@
#include "BLT_translation.h"
#include "BKE_animsys.h"
#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_idcode.h"
#include "BKE_idprop.h"
@@ -5778,6 +5779,11 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
*r_path = "node_tree";
}
return BKE_node_tree_find_owner_ID(bmain, (bNodeTree *)id);
case ID_GR:
if (r_path) {
*r_path = "collection";
}
return (ID *)BKE_collection_master_scene_search(bmain, (Collection *)id);
default:
return NULL;