Fix T102797: Unlinking an Orphan Action crashes

In `Orphan Data` (or `Blender File`) view, the ID pointer of the
actions's parent tree-element wasn't actually pointing to an ID, but to
the list-base containing the IDs.

Early out (with a warning) if the object or object-data to unlink the
action from is not clear.

Caused by rBb4a2096415d9.

Similar to rBe772087ed664.

Maniphest Tasks: T102797

Differential Revision: https://developer.blender.org/D16635
This commit is contained in:
Philipp Oeser 2022-11-28 10:44:19 +01:00
parent 48143ab001
commit e97443478e
Notes: blender-bot 2023-02-14 10:21:10 +01:00
Referenced by commit a3c38667f0, Fix T103881: Unlink operation crash in Blender File view
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3
Referenced by issue #102797, Regression: Unlinking an Orphan Action Crashes Blender
1 changed files with 14 additions and 2 deletions

View File

@ -216,13 +216,25 @@ static bool outliner_operation_tree_element_poll(bContext *C)
}
static void unlink_action_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 action 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 action '%s'. It's not clear which object or object-data it "
"should be unlinked from, there's no object or object-data as parent in the "
"Outliner tree",
tselem->id->name + 2);
return;
}
/* just set action to nullptr */
BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, nullptr);
DEG_id_tag_update(tsep->id, ID_RECALC_ANIMATION);