Page MenuHome

Crash on deleting current workspace from the outliner
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 970/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 445.75

Blender Version
Broken: version: 2.83 (sub 12), branch: master, commit date: 2020-04-07 11:44, hash: rB6feeede47ffa
Worked: technically 2.79b

Short description of error
You can use the outliner to delete workspace data. When you delete the workspace you are currently in Blender will crash.
I understand that this is something you have to provoke, but I guess that this could be handled a bit more gracefully

Exact steps for others to reproduce the error

  • Set the display mode in the outliner to "Blender File"
  • Twirl out "Workspaces"
  • Delete the one you are currently in

Related Objects

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Apr 7 2020, 4:28 PM
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Confirmed, checking...

Philipp Oeser (lichtwerk) renamed this task from Crash on deleting current workspace to Crash on deleting current workspace from the outliner.Apr 7 2020, 4:29 PM

Seems like the screen is already invalid (WM_window_get_active_screen, CTX_wm_screen return NULL), while the workspace is still valid (WM_window_get_active_workspace still gets the only just deleted...)

1 ED_screen_do_listen   screen_edit.c     440 0x3549f9b 
2 wm_event_do_notifiers wm_event_system.c 521 0x2ea82b9 
3 WM_main               wm.c              453 0x2ea3b04 
4 main                  creator.c         524 0x2a63259

Not sure exactly how to do this, but instead of the generic BKE_id_delete, we would need the functionality of ED_workspace_delete [doing it properly with ED_workspace_change etc...]

I could dig some more, but maybe @Bastien Montagne (mont29), @Julian Eisel (Severin) know right away?

Brecht Van Lommel (brecht) triaged this task as Low priority.Apr 7 2020, 5:37 PM

Deleting a workspace that is in use should just not be allowed I think,

Deleting a workspace that is in use should just not be allowed I think,

(works if you do it from the workspace tab context menu directly -- just not in the outliner...)

Right, but the workspace tab menu will change to another workspace first, and also will do nothing if there is only a single workspace.

For low-level access through the outliner or API I think we should only delete or refuse to delete, not change the active workspace.

I propose this as a simple fix:

1diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
2index 60e6b423720..3ae100b6209 100644
3--- a/source/blender/editors/space_outliner/outliner_edit.c
4+++ b/source/blender/editors/space_outliner/outliner_edit.c
5@@ -54,6 +54,7 @@
6 #include "BKE_outliner_treehash.h"
7 #include "BKE_report.h"
8 #include "BKE_scene.h"
9+#include "BKE_workspace.h"
10
11 #include "DEG_depsgraph.h"
12 #include "DEG_depsgraph_build.h"
13@@ -473,6 +474,14 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto
14 id->name);
15 return;
16 }
17+ else if (te->idcode == ID_WS) {
18+ BKE_workspace_id_tag_all_visible(bmain, LIB_TAG_DOIT);
19+ if (id->tag & LIB_TAG_DOIT) {
20+ BKE_reportf(
21+ reports, RPT_WARNING, "Cannot delete currently visible workspace id '%s'", id->name);
22+ return;
23+ }
24+ }
25
26 BKE_id_delete(bmain, id);
27

I don't want it to fail silently but give an error message, so this seemed like the best place to do that without bigger changes.