Fix T66955: Cannot delete data from file in outliner.

That switch on ID types had not been updated since quiet some time it’d
seem... Using the ID_Type enum type now, so this should not happen again
(compiler will yell at you if you forget to add here any new ID type ;) ).

Also had to change a bit the code layout then, to deal with fake NLA ID
type...

Note that for now, Screen IDs remain excluded from the ID menu usage,
due to T67004.
This commit is contained in:
Bastien Montagne 2019-07-15 18:06:32 +02:00
parent 9cdd2df277
commit 0b25566143
Notes: blender-bot 2023-02-14 06:37:09 +01:00
Referenced by issue #66955, Cannot delete data from file in outliner
1 changed files with 39 additions and 12 deletions

View File

@ -109,8 +109,9 @@ static void set_operation_types(SpaceOutliner *soops,
}
}
else {
int idcode = GS(tselem->id->name);
switch (idcode) {
const int idcode = (int)GS(tselem->id->name);
bool is_standard_id = false;
switch ((ID_Type)idcode) {
case ID_SCE:
*scenelevel = 1;
break;
@ -134,21 +135,47 @@ static void set_operation_types(SpaceOutliner *soops,
case ID_KE:
case ID_WO:
case ID_AC:
case ID_NLA:
case ID_TXT:
case ID_GR:
case ID_LS:
case ID_LI:
if (*idlevel == 0) {
*idlevel = idcode;
}
else if (*idlevel != idcode) {
*idlevel = -1;
}
if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) {
*datalevel = 0;
}
case ID_VF:
case ID_NT:
case ID_BR:
case ID_PA:
case ID_GD:
case ID_MC:
case ID_MSK:
case ID_PAL:
case ID_PC:
case ID_CF:
case ID_WS:
case ID_LP:
is_standard_id = true;
break;
case ID_WM:
case ID_SCR:
/* Those are ignored here. */
/* Note: while Screens should be manageable here, deleting a screen used by a workspace
* will cause crashes when trying to use that workspace, so for now let's play minimal,
* safe change. */
break;
}
if (idcode == ID_NLA) {
/* Fake one, not an actual ID type... */
is_standard_id = true;
}
if (is_standard_id) {
if (*idlevel == 0) {
*idlevel = idcode;
}
else if (*idlevel != idcode) {
*idlevel = -1;
}
if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) {
*datalevel = 0;
}
}
}
}