diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-06-28 11:10:43 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-06-28 11:22:53 +0300 |
commit | 9bcab8050f44e5bd36a0715811ee0355e4b221b6 (patch) | |
tree | 31d3d4abe5027df7759ae8dd8174fccd02fcb45b /source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | |
parent | eac11046a151dd1dfc175f2c3faf00a3baa99956 (diff) |
Fix T63694: Crash using tool gizmos with multiple windows
Gizmo group types now store a user count so they aren't unlinked
while other tools are using them.
The tool system now works with multiple windows.
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c')
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index f996d938dd7..40d99ce8ba6 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -70,7 +70,9 @@ wmGizmoGroup *wm_gizmogroup_new_from_type(wmGizmoMap *gzmap, wmGizmoGroupType *gzgt) { wmGizmoGroup *gzgroup = MEM_callocN(sizeof(*gzgroup), "gizmo-group"); + gzgroup->type = gzgt; + gzgroup->type->users += 1; /* keep back-link */ gzgroup->parent_gzmap = gzmap; @@ -130,9 +132,23 @@ void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup) BLI_remlink(&gzmap->groups, gzgroup); + if (gzgroup->tag_remove == false) { + gzgroup->type->users -= 1; + } + MEM_freeN(gzgroup); } +void WM_gizmo_group_tag_remove(wmGizmoGroup *gzgroup) +{ + if (gzgroup->tag_remove == false) { + gzgroup->tag_remove = true; + gzgroup->type->users -= 1; + BLI_assert(gzgroup->type->users >= 0); + WM_gizmoconfig_update_tag_group_remove(gzgroup->parent_gzmap); + } +} + /** * Add \a gizmo to \a gzgroup and make sure its name is unique within the group. */ @@ -1099,4 +1115,20 @@ void WM_gizmo_group_type_unlink_delayed(const char *idname) WM_gizmo_group_type_unlink_delayed_ptr(gzgt); } +void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt, + wmGizmoMapType *gzmap_type, + ScrArea *sa) +{ + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + wmGizmoMap *gzmap = ar->gizmo_map; + if (gzmap && gzmap->type == gzmap_type) { + for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + if (gzgroup->type == gzgt) { + WM_gizmo_group_tag_remove(gzgroup); + } + } + } + } +} + /** \} */ |