fix [#35434] Segmentation fault switching screen layout from python
authorCampbell Barton <ideasman42@gmail.com>
Sun, 2 Jun 2013 20:59:00 +0000 (20:59 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 2 Jun 2013 20:59:00 +0000 (20:59 +0000)
(take 2), only free popup handlers.

source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_handlers.c
source/blender/windowmanager/intern/wm_event_system.c

index a602fd272221a8459926f0aeef3f4a87c819fe41..e64a5a4af577fc03666bdce96dc15b9a628613f2 100644 (file)
@@ -687,6 +687,7 @@ void uiScalePanels(struct ARegion *ar, float new_width);
 void UI_add_region_handlers(struct ListBase *handlers);
 void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup);
 void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup);
+void UI_remove_popup_handlers_all(struct bContext *C, struct ListBase *handlers);
 
 /* Module
  *
index c5211fe9dd7b4c175f83a0b2927a4585fe65d85f..22880d8e79c57221b5af83ec69bedb52dfde283a 100644 (file)
@@ -7662,6 +7662,11 @@ void UI_remove_popup_handlers(ListBase *handlers, uiPopupBlockHandle *popup)
        WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup, FALSE);
 }
 
+void UI_remove_popup_handlers_all(bContext *C, ListBase *handlers)
+{
+       WM_event_free_ui_handler_all(C, handlers, ui_handler_popup, ui_handler_remove_popup);
+}
+
 bool UI_textbutton_activate_event(const bContext *C, ARegion *ar,
                                   const void *rna_poin_data, const char *rna_prop_id)
 {
index 91b7b81940b26665f6efd870508a426cef4ffb0c..de961afefd829872f02303a4c9fa48f4013ace7d 100644 (file)
@@ -247,7 +247,10 @@ void wm_event_do_notifiers(bContext *C)
                        if (note->window == win) {
                                if (note->category == NC_SCREEN) {
                                        if (note->data == ND_SCREENBROWSE) {
-                                               /* do not free handlers here! [#35434] */
+                                               /* free popup handlers only [#35434] */
+                                               wmWindow *win = CTX_wm_window(C);
+                                               UI_remove_popup_handlers_all(C, &win->modalhandlers);
+
 
                                                ED_screen_set(C, note->reference);  // XXX hrms, think this over!
                                                if (G.debug & G_DEBUG_EVENTS)