fix for crash with toggle-drag on a popup (when the popup is closed while dragging).
authorCampbell Barton <ideasman42@gmail.com>
Fri, 17 May 2013 13:54:44 +0000 (13:54 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 17 May 2013 13:54:44 +0000 (13:54 +0000)
source/blender/editors/interface/interface_handlers.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c

index e46def3be6fb83ce983072ce8f04f030b1d47eb5..c5211fe9dd7b4c175f83a0b2927a4585fe65d85f 100644 (file)
@@ -7606,6 +7606,14 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata)
                ui_popup_block_free(C, menu);
                UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu);
 
+#ifdef USE_DRAG_TOGGLE
+               {
+                       wmWindow *win = CTX_wm_window(C);
+                       WM_event_free_ui_handler_all(C, &win->modalhandlers,
+                                                    ui_handler_region_drag_toggle, ui_handler_region_drag_toggle_remove);
+               }
+#endif
+
                if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) {
                        if (temp.popup_func)
                                temp.popup_func(C, temp.popup_arg, temp.retvalue);
index 585201bc559992bfe6e1483d54b0a6480143e4f1..9830dcb9e9f9b985af03602917f547d536de14e4 100644 (file)
@@ -159,6 +159,9 @@ void                WM_event_remove_ui_handler(ListBase *handlers,
                                        void (*remove)(struct bContext *C, void *userdata),
                                        void *userdata, const bool postpone);
 void           WM_event_remove_area_handler(struct ListBase *handlers, void *area);
+void           WM_event_free_ui_handler_all(struct bContext *C, ListBase *handlers,
+                                         int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
+                                         void (*remove)(struct bContext *C, void *userdata));
 
 struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
 void           WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
index 89dc6ccc03830f00af158d4f17b924e763e3d831..03a1785541eb9af9a81eb5ac040a6b718f578883 100644 (file)
@@ -2476,6 +2476,21 @@ void WM_event_remove_ui_handler(ListBase *handlers,
        }
 }
 
+void WM_event_free_ui_handler_all(bContext *C, ListBase *handlers,
+                                  wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove)
+{
+       wmEventHandler *handler, *handler_next;
+
+       for (handler = handlers->first; handler; handler = handler_next) {
+               handler_next = handler->next;
+               if (handler->ui_handle == func && handler->ui_remove == remove) {
+                       remove(C, handler->ui_userdata);
+                       BLI_remlink(handlers, handler);
+                       wm_event_free_handler(handler);
+               }
+       }
+}
+
 wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes)
 {
        wmEventHandler *handler;