[Bf-blender-cvs] [0b255661435] master: Fix T66955: Cannot delete data from file in outliner.

Bastien Montagne noreply at git.blender.org
Mon Jul 15 18:10:39 CEST 2019


Commit: 0b255661435ab7021db3acafe15abe6ea0b946b5
Author: Bastien Montagne
Date:   Mon Jul 15 18:06:32 2019 +0200
Branches: master
https://developer.blender.org/rB0b255661435ab7021db3acafe15abe6ea0b946b5

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.

===================================================================

M	source/blender/editors/space_outliner/outliner_tools.c

===================================================================

diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index a618f8ef4c2..89eb3b9d953 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -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;
+          }
         }
       }
     }



More information about the Bf-blender-cvs mailing list