Commit: 721f38439e013a8d7e4acbfc88f2186568c1bb41
Author: Julian Eisel
Date:   Mon Dec 21 19:01:19 2015 +0100
Branches: temp_widgets_c++_experiment
https://developer.blender.org/rB721f38439e013a8d7e4acbfc88f2186568c1bb41

Generalize deleting of wmWidget types

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

M       source/blender/blenkernel/intern/screen.c
M       source/blender/editors/space_graph/graph_edit.c
M       source/blender/editors/space_sequencer/sequencer_view.c
M       source/blender/windowmanager/intern/widgets/wm_widget.cc
M       source/blender/windowmanager/intern/widgets/wm_widget.h
M       source/blender/windowmanager/intern/widgets/wm_widgetgroup.cc
M       source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
M       source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cc
M       source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
M       source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
M       source/blender/windowmanager/intern/widgets/wm_widgetmap.h
M       source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc
M       source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
M       source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/blenkernel/intern/screen.c 
b/source/blender/blenkernel/intern/screen.c
index 27621d9..2344bea 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -341,8 +341,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
                }
        }
 
-       WM_widgetmaps_delete(&ar->widgetmaps);
-       BLI_listbase_clear(&ar->widgetmaps);
+       WM_widgetmaps_remove(&ar->widgetmaps);
        BLI_freelistN(&ar->ui_lists);
        BLI_freelistN(&ar->ui_previews);
        BLI_freelistN(&ar->panels_category);
diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index 8047c47..9ec3a61 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2661,7 +2661,7 @@ static void 
graph_widget_backdrop_transform_finish(bContext *C, BackDropTransfor
 {
        ScrArea *sa = CTX_wm_area(C);
        ED_area_headerprint(sa, NULL);
-       WM_widgetgrouptype_delete(C, CTX_data_main(C), data->cagetype);
+       WM_widgetgrouptype_remove(C, CTX_data_main(C), data->cagetype);
        MEM_freeN(data);
 }
 
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c 
b/source/blender/editors/space_sequencer/sequencer_view.c
index dfb513c..cb8163b 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -320,7 +320,7 @@ static void sequencer_overdrop_finish(bContext *C, 
OverDropTransformData *data)
 {
        ScrArea *sa = CTX_wm_area(C);
        ED_area_headerprint(sa, NULL);
-       WM_widgetgrouptype_delete(C, CTX_data_main(C), data->cagetype);
+       WM_widgetgrouptype_remove(C, CTX_data_main(C), data->cagetype);
        MEM_freeN(data);
 }
 
@@ -489,7 +489,7 @@ static void 
sequencer_image_transform_widget_finish(bContext *C, ImageTransformD
 {
        ScrArea *sa = CTX_wm_area(C);
        ED_area_headerprint(sa, NULL);
-       WM_widgetgrouptype_delete(C, CTX_data_main(C), data->cagetype);
+       WM_widgetgrouptype_remove(C, CTX_data_main(C), data->cagetype);
        MEM_freeN(data);
 }
 
diff --git a/source/blender/windowmanager/intern/widgets/wm_widget.cc 
b/source/blender/windowmanager/intern/widgets/wm_widget.cc
index aa88754..d2db13d 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widget.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widget.cc
@@ -71,7 +71,7 @@ void widget_data_free(wmWidget *widget)
  * Free and NULL \a widget.
  * \a widgetlist is allowed to be NULL.
  */
-void widget_delete(ListBase *widgetlist, wmWidget *widget)
+void widget_remove(ListBase *widgetlist, wmWidget *widget)
 {
        widget_data_free(widget);
        if (widgetlist)
diff --git a/source/blender/windowmanager/intern/widgets/wm_widget.h 
b/source/blender/windowmanager/intern/widgets/wm_widget.h
index a873e05..2e16642 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widget.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widget.h
@@ -60,7 +60,7 @@ public:
 };
 #endif
 
-void widget_delete(ListBase *widgetlist, wmWidget *widget);
+void widget_remove(ListBase *widgetlist, wmWidget *widget);
 void widget_data_free(wmWidget *widget);
 void widget_find_active_3D_loop(const bContext *C, ListBase *visible_widgets);
 void widget_calculate_scale(wmWidget *widget, const bContext *C);
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cc 
b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cc
index 6af9fb9..09b2ab3 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cc
@@ -53,9 +53,11 @@ wmWidgetGroup::wmWidgetGroup()
 }
 #endif
 
-void widgetgroup_free(bContext *C, wmWidgetMap *wmap, wmWidgetGroup *wgroup)
+void widgetgroup_remove(bContext *C, wmWidgetMap *wmap, wmWidgetGroup *wgroup)
 {
-       for (wmWidget *widget = (wmWidget *)wgroup->widgets.first; widget;) {
+       wmWidget *widget = (wmWidget *)wgroup->widgets.first;
+
+       while (widget) {
                wmWidget *widget_next = widget->next;
                if (widget->flag & WM_WIDGET_HIGHLIGHT) {
                        wmap->set_highlighted_widget(C, NULL, 0);
@@ -63,10 +65,13 @@ void widgetgroup_free(bContext *C, wmWidgetMap *wmap, 
wmWidgetGroup *wgroup)
                if (widget->flag & WM_WIDGET_ACTIVE) {
                        wmap->set_active_widget(C, NULL, NULL);
                }
-               widget_delete(&wgroup->widgets, widget);
+
+               widget_remove(&wgroup->widgets, widget);
                widget = widget_next;
        }
 
+       BLI_remlink(&wmap->widgetgroups, wgroup);
+
 #ifdef WITH_PYTHON
        if (wgroup->py_instance) {
                /* do this first in case there are any __del__ functions or
@@ -80,7 +85,6 @@ void widgetgroup_free(bContext *C, wmWidgetMap *wmap, 
wmWidgetGroup *wgroup)
                MEM_freeN(wgroup->reports);
        }
 
-       BLI_remlink(&wmap->widgetgroups, wgroup);
-       MEM_freeN(wgroup);
+       delete wgroup;
 }
 
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h 
b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
index 8779ee5..3dc46b3 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
@@ -43,6 +43,6 @@ public:
 };
 #endif
 
-void widgetgroup_free(bContext *C, struct wmWidgetMap *wmap, wmWidgetGroup 
*wgroup);
+void widgetgroup_remove(bContext *C, struct wmWidgetMap *wmap, wmWidgetGroup 
*wgroup);
 
 #endif // __WM_WIDGETGROUP_H__
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cc 
b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cc
index d20b61e..e61ae80 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cc
@@ -108,7 +108,14 @@ wmWidgetGroupType::wmWidgetGroupType(
        }
 }
 
-void wmWidgetGroupType::free(bContext *C, Main *bmain)
+#if 0 /* not needed yet */
+wmWidgetGroupType::~wmWidgetGroupType()
+{
+       
+}
+#endif
+
+void wmWidgetGroupType::unregister(bContext *C, Main *bmain)
 {
        for (bScreen *sc = (bScreen *)bmain->screen.first; sc; sc = (bScreen 
*)sc->id.next) {
                for (ScrArea *sa = (ScrArea *)sc->areabase.first; sa; sa = 
sa->next) {
@@ -121,7 +128,7 @@ void wmWidgetGroupType::free(bContext *C, Main *bmain)
                                                for (wgroup = (wmWidgetGroup 
*)wmap->widgetgroups.first; wgroup; wgroup = wgroup_next) {
                                                        wgroup_next = 
wgroup->next;
                                                        if (wgroup->type == 
this) {
-                                                               
widgetgroup_free(C, wmap, wgroup);
+                                                               
widgetgroup_remove(C, wmap, wgroup);
                                                                
ED_region_tag_redraw(ar);
                                                        }
                                                }
@@ -131,14 +138,10 @@ void wmWidgetGroupType::free(bContext *C, Main *bmain)
                }
        }
 
+
        wmWidgetMapType *wmaptype = WM_widgetmaptype_find(mapidname, spaceid,
                                                          regionid, is_3d, 
false);
-
        BLI_remlink(&wmaptype->widgetgrouptypes, this);
-       prev = next = NULL;
-
-       // yay, suicide
-       delete this;
 }
 
 void wmWidgetGroupType::keymap_init_do(wmKeyConfig *keyconf)
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h 
b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
index a839dae..df2e640 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
@@ -49,9 +49,6 @@ class wmWidgetGroupType
 public:
        wmWidgetGroupType *next, *prev;
 
-       /**
-        * \brief wmWidgetGroupType Constructor
-        */
        wmWidgetGroupType(
                wmWidgetMapType *wmaptype,
                int (*poll)(const bContext *, wmWidgetGroupType *),
@@ -59,7 +56,7 @@ public:
                wmKeyMap *(*keymap_init)(wmKeyConfig *, const char *),
                const Main *bmain, const char *mapidname, const char *name,
                const short spaceid, const short regionid, const bool is_3d);
-       void free(bContext *C, Main *bmain);
+       void unregister(bContext *C, Main *bmain);
 
        void keymap_init_do(wmKeyConfig *keyconf);
        void attach_to_handler(bContext *C, struct wmEventHandler *handler, 
struct wmOperator *op_);
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc 
b/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
index 2d5627d..e30fe91 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
@@ -79,19 +79,22 @@ wmWidgetMap::wmWidgetMap(const char *idname, const int 
spaceid, const int region
        }
 }
 
+/**
+ * \brief wmWidgetMap Destructor
+ *
+ * \warning As it currently is, this may only be called on exit/startup. If 
called on runtime,
+ *          bContext * should be passed to #widgetgroup_remove so cursor can 
be reset.
+ */
 wmWidgetMap::~wmWidgetMap()
 {
-       for (wmWidgetGroup *wgroup = (wmWidgetGroup *)widgetgroups.first; 
wgroup;) {
-               wmWidgetGroup *wgroup_next = wgroup->next;
+       wmWidgetGroup *wgroup = (wmWidgetGroup *)widgetgroups.first;
 
-               for (wmWidget *widget = (wmWidget *)wgroup->widgets.first; 
widget;) {
-                       wmWidget *widget_next = widget->next;
-                       widget_delete(&wgroup->widgets, widget);
-                       widget = widget_next;
-               }
+       while (wgroup) {
+               wmWidgetGroup *wgroup_next = wgroup->next;
 
-               /* XXX should actually share code with widgetgroup_free, but 
needs to be done carefully */
-               delete wgroup;
+               /* bContext * can be NULL since this destructor is only called
+                * on exit and we don't need to change cursor state */
+               widgetgroup_remove(NULL, this, wgroup);
                wgroup = wgroup_next;
        }
 
@@ -99,15 +102,25 @@ wmWidgetMap::~wmWidgetMap()
        MEM_SAFE_FREE(wmap_context.selected_widgets);
 }
 
-void WM_widgetmaps_delete(ListBase *widgetmaps)
+void wmWidgetMap::unregister(ListBase *widgetmaps)
+{
+       BLI_remlink(widgetmaps, this);
+}
+
+/**
+ * \brief Remove all widgetmaps of ListBase \a widgetmaps.
+ */
+void WM_widgetmaps_remove(ListBase *widgetmaps)
 {
        wmWidgetMap *wmap = (wmWidgetMap *)widgetmaps->first;
 
        while (wmap) {
                wmWidgetMap *wmap_next = wmap->next;
-               WM_widgetmap_delete(wmap);
+               WM_widgetmap_remove(wmap, widgetmaps);
                wmap = wmap_next;
        }
+
+       BLI_assert(BLI_listbase_is_empty(widgetmaps));
 }
 
 static void widget_highlight_update(wmWidgetMap *wmap, const wmWidget *old_, 
wmWidget *new_)
@@ -152,7 +165,7 @@ void wmWidgetMap::update(const bContext *C)
                                                widget->next = widget->prev = 
NULL;
                                        }
                                        else {
-                                               widget_delete(&wgroup->widgets, 
widget);
+

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to