Tool System: don't unlink gizmos when changing tools

Needed for tools not to unlink each other with multiple windows.
This commit is contained in:
Campbell Barton 2019-06-27 18:42:25 +10:00
parent 3366b333e4
commit c93af8529d
Notes: blender-bot 2023-12-08 16:39:08 +01:00
Referenced by commit 83d92f55b8, Fix error for tools that share gizmo types doubling up gizmos
1 changed files with 10 additions and 5 deletions

View File

@ -128,11 +128,16 @@ bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, const bToolKey *tkey,
/** \} */
static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
/**
* \param do_gizmo: Make removing the gizmo optional because it complicates multi-window support
* since the tool might be used in another window. The gizmos poll function must handle this,
* since this is needed for switching workspaces anyway.
*/
static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *tref, bool do_gizmo)
{
bToolRef_Runtime *tref_rt = tref->runtime;
if (tref_rt->gizmo_group[0]) {
if (do_gizmo && tref_rt->gizmo_group[0]) {
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false);
if (gzgt != NULL) {
bool found = false;
@ -165,7 +170,7 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
{
bToolRef *tref = WM_toolsystem_ref_find(workspace, tkey);
if (tref && tref->runtime) {
toolsystem_unlink_ref(C, workspace, tref);
toolsystem_unlink_ref(C, workspace, tref, false);
}
}
@ -312,7 +317,7 @@ void WM_toolsystem_unlink_all(struct bContext *C, struct WorkSpace *workspace)
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
if (tref->runtime) {
if (tref->tag == 0) {
toolsystem_unlink_ref(C, workspace, tref);
toolsystem_unlink_ref(C, workspace, tref, true);
tref->tag = 1;
}
}
@ -359,7 +364,7 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
Main *bmain = CTX_data_main(C);
if (tref->runtime) {
toolsystem_unlink_ref(C, workspace, tref);
toolsystem_unlink_ref(C, workspace, tref, false);
}
STRNCPY(tref->idname, idname);