[Bf-blender-cvs] [2daae19] wiggly-widgets: Fix memory leak for widgets w/o own interaction handling

Julian Eisel noreply at git.blender.org
Sat Sep 19 22:47:41 CEST 2015


Commit: 2daae192276bf8b1d5115a92beaa534c8fcbb4fb
Author: Julian Eisel
Date:   Sat Sep 19 22:40:07 2015 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB2daae192276bf8b1d5115a92beaa534c8fcbb4fb

Fix memory leak for widgets w/o own interaction handling

===================================================================

M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_generic_widgets.c
M	source/blender/windowmanager/intern/wm_widgets.c

===================================================================

diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 58515ac..d8453af 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -519,9 +519,10 @@ enum widgetflags {
 	WM_WIDGET_ACTIVE      = (1 << 1),
 	/* settings */
 	WM_WIDGET_DRAW_HOVER  = (1 << 2),
-	WM_WIDGET_SCALE_3D    = (1 << 3),
-	WM_WIDGET_SCENE_DEPTH = (1 << 4), /* widget is depth culled with scene objects*/
-	WM_WIDGET_HIDDEN      = (1 << 5),
+	WM_WIDGET_DRAW_ACTIVE = (1 << 3), /* draw while dragging */
+	WM_WIDGET_SCALE_3D    = (1 << 4),
+	WM_WIDGET_SCENE_DEPTH = (1 << 5), /* widget is depth culled with scene objects*/
+	WM_WIDGET_HIDDEN      = (1 << 6),
 };
 
 void WM_widget_set_property(struct wmWidget *, int slot, struct PointerRNA *ptr, const char *propname);
diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
index 574b661..bfc0556 100644
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ b/source/blender/windowmanager/intern/wm_generic_widgets.c
@@ -636,7 +636,7 @@ wmWidget *WIDGET_arrow_new(wmWidgetGroup *wgroup, const char *name, const int st
 	arrow->widget.render_3d_intersection = widget_arrow_render_3d_intersect;
 	arrow->widget.bind_to_prop = widget_arrow_bind_to_prop;
 	arrow->widget.cancel = widget_arrow_cancel;
-	arrow->widget.flag |= WM_WIDGET_SCALE_3D;
+	arrow->widget.flag |= (WM_WIDGET_SCALE_3D | WM_WIDGET_DRAW_ACTIVE);
 
 	arrow->style = real_style;
 	arrow->len = 1.0f;
@@ -1514,6 +1514,7 @@ wmWidget *WIDGET_rect_transform_new(
 	cage->widget.cancel = widget_rect_transform_cancel;
 	cage->widget.get_cursor = widget_rect_transform_get_cursor;
 	cage->widget.max_prop = 2;
+	cage->widget.flag |= WM_WIDGET_DRAW_ACTIVE;
 	cage->scale[0] = cage->scale[1] = 1.0f;
 	cage->style = style;
 	cage->w = width;
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index 616a596..fce4230 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -310,9 +310,11 @@ void WM_widgets_draw(const bContext *C, const wmWidgetMap *wmap, const bool in_s
 	widget = wmap->active_widget;
 
 	if (widget && in_scene == ((widget->flag & WM_WIDGET_SCENE_DEPTH) != 0)) {
-		/* notice that we don't update the widgetgroup, widget is now on its own, it should have all
-		 * relevant data to update itself */
-		widget->draw(C, widget);
+		if (widget->flag & WM_WIDGET_DRAW_ACTIVE) {
+			/* notice that we don't update the widgetgroup, widget is now on
+			 * its own, it should have all relevant data to update itself */
+			widget->draw(C, widget);
+		}
 	}
 	else if (wmap->widgetgroups.first) {
 		wmWidgetGroup *wgroup;
@@ -754,8 +756,8 @@ void wm_widgetmap_set_active_widget(
 				if (widget->invoke && widget->handler) {
 					widget->flag |= WM_WIDGET_ACTIVE;
 					widget->invoke(C, event, widget);
-					wmap->active_widget = widget;
 				}
+				wmap->active_widget = widget;
 
 				/* if operator runs modal, we will need to activate the current widgetmap on the operator handler,
 				 * so it can process events first, then pass them on to the operator */




More information about the Bf-blender-cvs mailing list