Fix #108722 : Measures not cleared when removing annotation layer #108749

Open
Philipp Oeser wants to merge 2 commits from lichtwerk/blender:108722 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 29 additions and 1 deletions

View File

@ -65,6 +65,7 @@
#include "ED_gpencil_legacy.h"
#include "ED_object.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@ -332,6 +333,10 @@ static int gpencil_layer_remove_exec(bContext *C, wmOperator *op)
BKE_gpencil_layer_active_set(gpd, gpl->next);
}
if (gpl->flag & GP_LAYER_IS_RULER) {
ED_view3d_gizmo_ruler_remove_all(C);
}
/* delete the layer now... */
BKE_gpencil_layer_delete(gpd, gpl);

View File

@ -1364,6 +1364,13 @@ void ED_view3d_gizmo_mesh_preselect_get_active(struct bContext *C,
struct BMElem **r_ele);
void ED_view3d_gizmo_mesh_preselect_clear(struct wmGizmo *gz);
/* view3d_gizmo_ruler.cc */
/**
* Remove all rulers when Annotation layer is removed.
*/
void ED_view3d_gizmo_ruler_remove_all(struct bContext *C);
/* space_view3d.cc */
void ED_view3d_buttons_region_layout_ex(const struct bContext *C,

View File

@ -621,6 +621,20 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup)
return changed;
}
void ED_view3d_gizmo_ruler_remove_all(bContext *C)
{
ARegion *region = CTX_wm_region(C);
wmGizmoMap *gzmap = region->gizmo_map;
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
RulerItem *ruler_item;
while ((ruler_item = gzgroup_ruler_item_first_get(gzgroup))) {
ruler_item_remove(C, gzgroup, ruler_item);
}
ED_region_tag_redraw_editor_overlays(region);
}
/** \} */
/* -------------------------------------------------------------------- */
@ -1189,7 +1203,9 @@ static void gizmo_ruler_exit(bContext *C, wmGizmo *gz, const bool cancel)
ruler_state_set(ruler_info, RULER_STATE_NORMAL);
}
/* We could convert only the current gizmo, for now just re-generate. */
view3d_ruler_to_gpencil(C, gzgroup);
if (view3d_ruler_to_gpencil(C, gzgroup)) {
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
}
}
MEM_SAFE_FREE(gz->interaction_data);