Workspace duplicate resets my tweak tool back to default select box #75312

Open
opened 2020-04-02 15:42:54 +02:00 by Vyacheslav Kobozev · 6 comments

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 442.59

Blender Version
Broken: version: 2.83 (sub 11), branch: master, commit date: 2020-03-30 22:07, hash: b555b8dedc
Worked: ???

Short description of error
And EACH time I create new workspace I forced to change it back to tweak, because i prefer it.
It is a pain in the … code.

Why do I think it is a bug? Because scale cage or annotation are saved.
2020-04-02_16-44-41.mp4

**System Information** Operating system: Windows-7-6.1.7601-SP1 64 Bits Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 442.59 **Blender Version** Broken: version: 2.83 (sub 11), branch: master, commit date: 2020-03-30 22:07, hash: `b555b8dedc` Worked: ??? **Short description of error** And EACH time I create new workspace I forced to change it back to tweak, because i prefer it. It is a pain in the … code. Why do I think it is a bug? Because scale cage or annotation are saved. [2020-04-02_16-44-41.mp4](https://archive.blender.org/developer/F8443764/2020-04-02_16-44-41.mp4)

Added subscriber: @Vyach

Added subscriber: @Vyach
Member

Added subscribers: @JulianEisel, @ideasman42, @lichtwerk

Added subscribers: @JulianEisel, @ideasman42, @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Not really sure how this is supposed to work...

Because scale cage or annotation are saved

These dont seem to be unique/saved per workspace in general.
For example: If you choose different scale tools [Scale for one Scale Cage for the other] for different workspaces, then switch between the workspaces back and forth:

  • these are kept separate if the scale category is selected in both workspaces
  • these magically sync between the workspaces again if different categories are selected [lets say scale category in one, annotate category in the other...]

note there is a TODO comment in ED_workspace_duplicate()

/* TODO(campbell): tools */

CC @ideasman42
CC @JulianEisel

Will confirm for now [without saying it is a bug].

Not really sure how this is supposed to work... > Because scale cage or annotation are saved These dont seem to be unique/saved per workspace in general. For example: If you choose different scale tools [`Scale` for one `Scale Cage` for the other] for different workspaces, then switch between the workspaces back and forth: - these are kept separate if the **scale** category is selected in both workspaces - these magically sync between the workspaces again if different categories are selected [lets say **scale** category in one, **annotate** category in the other...] note there is a TODO comment in `ED_workspace_duplicate()` > /* TODO(campbell): tools */ CC @ideasman42 CC @JulianEisel Will confirm for now [without saying it is a bug].

@lichtwerk I see syncrinization for scale/annotation and, perhaps, it is good.
But tweak tool is not syncronized and do not inherit previous state.
So, at least, it is inconsistency and annoying thing. And may be error/flaw/missing in the code.

@lichtwerk I see syncrinization for scale/annotation and, perhaps, it is good. But tweak tool is not syncronized and do not inherit previous state. So, at least, it is inconsistency and annoying thing. And may be error/flaw/missing in the code.
Member

This seems to work, but I'd prefer @ideasman42 to check over this. I'm not sure at all which members need to be copied over exactly.

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index bc6a4b23609..33a7a8800cf 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -279,7 +279,8 @@ bool ED_workspace_change(struct WorkSpace *workspace_new,
                          struct bContext *C,
                          struct wmWindowManager *wm,
                          struct wmWindow *win) ATTR_NONNULL();
-struct WorkSpace *ED_workspace_duplicate(struct WorkSpace *workspace_old,
+struct WorkSpace *ED_workspace_duplicate(struct bContext *C,
+                                         struct WorkSpace *workspace_old,
                                          struct Main *bmain,
                                          struct wmWindow *win);
 bool ED_workspace_delete(struct WorkSpace *workspace,
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 8feef0c675a..4dc201bf809 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -53,6 +53,7 @@
 #include "BLT_translation.h"
 
 #include "WM_api.h"
+#include "WM_toolsystem.h"
 #include "WM_types.h"
 
 #include "screen_intern.h"
@@ -185,7 +186,10 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager
  * Duplicate a workspace including its layouts. Does not activate the workspace, but
  * it stores the screen-layout to be activated (BKE_workspace_temp_layout_store)
  */
-WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindow *win)
+WorkSpace *ED_workspace_duplicate(bContext *C,
+                                  WorkSpace *workspace_old,
+                                  Main *bmain,
+                                  wmWindow *win)
 {
   WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook);
   ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old);
@@ -196,7 +200,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo
   workspace_new->order = workspace_old->order;
   BLI_duplicatelist(&workspace_new->owner_ids, &workspace_old->owner_ids);
 
-  /* TODO(campbell): tools */
+  WM_toolsystem_refs_duplicate_to_workspace(C, workspace_old, workspace_new);
 
   LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) {
     WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(
@@ -279,7 +283,7 @@ static int workspace_new_exec(bContext *C, wmOperator *UNUSED(op))
   wmWindow *win = CTX_wm_window(C);
   WorkSpace *workspace = workspace_context_get(C);
 
-  workspace = ED_workspace_duplicate(workspace, bmain, win);
+  workspace = ED_workspace_duplicate(C, workspace, bmain, win);
 
   WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, workspace);
 
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 163f37be974..d4582b5c9c3 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -54,6 +54,9 @@ struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bTool
 bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace,
                               const bToolKey *tkey,
                               struct bToolRef **r_tref);
+void WM_toolsystem_refs_duplicate_to_workspace(struct bContext *C,
+                                               const struct WorkSpace *from_workspace,
+                                               struct WorkSpace *to_workspace);
 
 struct bToolRef *WM_toolsystem_ref_set_by_id_ex(struct bContext *C,
                                                 struct WorkSpace *workspace,
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 72969f34162..22f69b8ef40 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -126,6 +126,19 @@ bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, const bToolKey *tkey,
   return true;
 }
 
+void WM_toolsystem_refs_duplicate_to_workspace(bContext *C,
+                                               const WorkSpace *from_workspace,
+                                               WorkSpace *to_workspace)
+{
+  LISTBASE_FOREACH (bToolRef *, tref, &from_workspace->tools) {
+    bToolRef *new_tref;
+    WM_toolsystem_ref_ensure(
+        to_workspace, &(bToolKey){.space_type = tref->space_type, .mode = tref->mode}, &new_tref);
+    STRNCPY(new_tref->idname_fallback, tref->idname_fallback);
+    WM_toolsystem_ref_set_from_runtime(C, to_workspace, new_tref, tref->runtime, tref->idname);
+  }
+}
+
 /** \} */
 
 static void toolsystem_unlink_ref(bContext *C, WorkSpace *UNUSED(workspace), bToolRef *tref)

This seems to work, but I'd prefer @ideasman42 to check over this. I'm not sure at all which members need to be copied over exactly. ```lines=15 diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index bc6a4b23609..33a7a8800cf 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -279,7 +279,8 @@ bool ED_workspace_change(struct WorkSpace *workspace_new, struct bContext *C, struct wmWindowManager *wm, struct wmWindow *win) ATTR_NONNULL(); -struct WorkSpace *ED_workspace_duplicate(struct WorkSpace *workspace_old, +struct WorkSpace *ED_workspace_duplicate(struct bContext *C, + struct WorkSpace *workspace_old, struct Main *bmain, struct wmWindow *win); bool ED_workspace_delete(struct WorkSpace *workspace, diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 8feef0c675a..4dc201bf809 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -53,6 +53,7 @@ #include "BLT_translation.h" #include "WM_api.h" +#include "WM_toolsystem.h" #include "WM_types.h" #include "screen_intern.h" @@ -185,7 +186,10 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager * Duplicate a workspace including its layouts. Does not activate the workspace, but * it stores the screen-layout to be activated (BKE_workspace_temp_layout_store) */ -WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindow *win) +WorkSpace *ED_workspace_duplicate(bContext *C, + WorkSpace *workspace_old, + Main *bmain, + wmWindow *win) { WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); @@ -196,7 +200,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo workspace_new->order = workspace_old->order; BLI_duplicatelist(&workspace_new->owner_ids, &workspace_old->owner_ids); - /* TODO(campbell): tools */ + WM_toolsystem_refs_duplicate_to_workspace(C, workspace_old, workspace_new); LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) { WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( @@ -279,7 +283,7 @@ static int workspace_new_exec(bContext *C, wmOperator *UNUSED(op)) wmWindow *win = CTX_wm_window(C); WorkSpace *workspace = workspace_context_get(C); - workspace = ED_workspace_duplicate(workspace, bmain, win); + workspace = ED_workspace_duplicate(C, workspace, bmain, win); WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, workspace); diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 163f37be974..d4582b5c9c3 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -54,6 +54,9 @@ struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bTool bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, const bToolKey *tkey, struct bToolRef **r_tref); +void WM_toolsystem_refs_duplicate_to_workspace(struct bContext *C, + const struct WorkSpace *from_workspace, + struct WorkSpace *to_workspace); struct bToolRef *WM_toolsystem_ref_set_by_id_ex(struct bContext *C, struct WorkSpace *workspace, diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 72969f34162..22f69b8ef40 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -126,6 +126,19 @@ bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, const bToolKey *tkey, return true; } +void WM_toolsystem_refs_duplicate_to_workspace(bContext *C, + const WorkSpace *from_workspace, + WorkSpace *to_workspace) +{ + LISTBASE_FOREACH (bToolRef *, tref, &from_workspace->tools) { + bToolRef *new_tref; + WM_toolsystem_ref_ensure( + to_workspace, &(bToolKey){.space_type = tref->space_type, .mode = tref->mode}, &new_tref); + STRNCPY(new_tref->idname_fallback, tref->idname_fallback); + WM_toolsystem_ref_set_from_runtime(C, to_workspace, new_tref, tref->runtime, tref->idname); + } +} + /** \} */ static void toolsystem_unlink_ref(bContext *C, WorkSpace *UNUSED(workspace), bToolRef *tref) ```
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:24:43 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#75312
No description provided.