[Bf-blender-cvs] [a3c38667f0f] master: Fix T103881: Unlink operation crash in Blender File view
Pratik Borhade
noreply at git.blender.org
Thu Jan 19 11:36:25 CET 2023
Commit: a3c38667f0f8195ed560b32db5630ccaceb42d54
Author: Pratik Borhade
Date: Thu Jan 19 16:04:15 2023 +0530
Branches: master
https://developer.blender.org/rBa3c38667f0f8195ed560b32db5630ccaceb42d54
Fix T103881: Unlink operation crash in Blender File view
Similar to rBe97443478e32 and rBe772087ed664, exit early when
texture, collection and world ID has no parent to unlink from.
Reviewed by: Severin, lichtwerk
Differential Revision: https://developer.blender.org/D17017
===================================================================
M source/blender/editors/space_outliner/outliner_tools.cc
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc
index 01579eb0499..35373c510e3 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -329,13 +329,24 @@ static void unlink_material_fn(bContext * /*C*/,
}
static void unlink_texture_fn(bContext * /*C*/,
- ReportList * /*reports*/,
+ ReportList *reports,
Scene * /*scene*/,
TreeElement *te,
TreeStoreElem *tsep,
- TreeStoreElem * /*tselem*/,
+ TreeStoreElem *tselem,
void * /*user_data*/)
{
+ if (!tsep || !TSE_IS_REAL_ID(tsep)) {
+ /* Valid case, no parent element of the texture or it is not an ID (could be a #TSE_ID_BASE
+ * for example) so there's no data to unlink from. */
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Cannot unlink texture '%s'. It's not clear which freestyle line style it should "
+ "be unlinked from, there's no freestyle line style as parent in the Outliner tree",
+ tselem->id->name + 2);
+ return;
+ }
+
MTex **mtex = nullptr;
int a;
@@ -358,7 +369,7 @@ static void unlink_texture_fn(bContext * /*C*/,
}
static void unlink_collection_fn(bContext *C,
- ReportList * /*reports*/,
+ ReportList *reports,
Scene * /*scene*/,
TreeElement * /*te*/,
TreeStoreElem *tsep,
@@ -368,6 +379,18 @@ static void unlink_collection_fn(bContext *C,
Main *bmain = CTX_data_main(C);
Collection *collection = (Collection *)tselem->id;
+ if (!tsep || !TSE_IS_REAL_ID(tsep)) {
+ /* Valid case, no parent element of the collection or it is not an ID (could be a #TSE_ID_BASE
+ * for example) so there's no data to unlink from. */
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Cannot unlink collection '%s'. It's not clear which scene, collection or "
+ "instance empties it should be unlinked from, there's no scene, collection or "
+ "instance empties as parent in the Outliner tree",
+ tselem->id->name + 2);
+ return;
+ }
+
if (tsep) {
if (GS(tsep->id->name) == ID_OB) {
Object *ob = (Object *)tsep->id;
@@ -449,13 +472,24 @@ static void unlink_object_fn(bContext *C,
}
static void unlink_world_fn(bContext * /*C*/,
- ReportList * /*reports*/,
+ ReportList *reports,
Scene * /*scene*/,
TreeElement * /*te*/,
TreeStoreElem *tsep,
TreeStoreElem *tselem,
void * /*user_data*/)
{
+ if (!tsep || !TSE_IS_REAL_ID(tsep)) {
+ /* Valid case, no parent element of the world or it is not an ID (could be a #TSE_ID_BASE
+ * for example) so there's no data to unlink from. */
+ BKE_reportf(reports,
+ RPT_WARNING,
+ "Cannot unlink world '%s'. It's not clear which scene it should be unlinked from, "
+ "there's no scene as parent in the Outliner tree",
+ tselem->id->name + 2);
+ return;
+ }
+
Scene *parscene = (Scene *)tsep->id;
World *wo = (World *)tselem->id;
More information about the Bf-blender-cvs
mailing list