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
This commit is contained in:
parent
eb657633ed
commit
a3c38667f0
Notes:
blender-bot
2023-02-13 13:34:53 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #103881, Regression: Blender Crash when unlinking a Collection from Blender File
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue