Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2019-03-09 00:48:27 +0300
committerDalai Felinto <dfelinto@gmail.com>2019-03-09 00:52:32 +0300
commita0f2923fd821099039c6350f3e8666d1d4d37ec9 (patch)
tree5b01841a4b1b5452ee25506ee0c9d5a8ea41a342 /source/blender/editors/screen/workspace_edit.c
parentaa49444c291fd54e5e45576a28d36d72816a5469 (diff)
Fix active workspace changes when deleting workspace
Tested for multi-window as well, which failed with the previous code even before we introduced ordered workspaces.
Diffstat (limited to 'source/blender/editors/screen/workspace_edit.c')
-rw-r--r--source/blender/editors/screen/workspace_edit.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index b63a755368e..c777308e435 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -221,20 +221,31 @@ WorkSpace *ED_workspace_duplicate(
bool ED_workspace_delete(
WorkSpace *workspace, Main *bmain, bContext *C, wmWindowManager *wm)
{
- ID *workspace_id = (ID *)workspace;
-
if (BLI_listbase_is_single(&bmain->workspaces)) {
return false;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *prev = workspace_id->prev;
- WorkSpace *next = workspace_id->next;
+ ListBase ordered;
+ BKE_id_ordered_list(&ordered, &bmain->workspaces);
+ WorkSpace *prev = NULL, *next = NULL;
+ for (LinkData *link = ordered.first; link; link = link->next) {
+ if (link->data == workspace) {
+ prev = link->prev ? link->prev->data : NULL;
+ next = link->next ? link->next->data : NULL;
+ break;
+ }
+ }
+ BLI_freelistN(&ordered);
+ BLI_assert((prev != NULL) || (next != NULL));
- ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ WorkSpace *workspace_active = WM_window_get_active_workspace(win);
+ if (workspace_active == workspace) {
+ ED_workspace_change((prev != NULL) ? prev : next, C, wm, win);
+ }
}
- BKE_id_free(bmain, workspace_id);
+ BKE_id_free(bmain, &workspace->id);
return true;
}