fix crash with lots of operators when running "blender -d". Easy case to reproduce...
authorAndrea Weikert <elubie@gmx.net>
Wed, 20 Apr 2011 20:46:02 +0000 (20:46 +0000)
committerAndrea Weikert <elubie@gmx.net>
Wed, 20 Apr 2011 20:46:02 +0000 (20:46 +0000)
Temporary hack to prevent crasher, likely caused by rev. 36242.

source/blender/windowmanager/intern/wm_event_system.c

index c9e2567a45b372f835cd8ac9f2faa0436ac5e417..b2ed914ea2be0781cc587af57314ed95cb64163c 100644 (file)
@@ -1538,12 +1538,19 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                }
                
                /* modal ui handler can be tagged to be freed */ 
+               /* XXX TODO - handler was free'd in wm_handler_ui_call 
+                      and memory could be written to in BLI_remlink.
+                          As temporary solution preventing this by
+                          making sure handler is still in the list.
+               */   
+               
                if(handler->flag & WM_HANDLER_DO_FREE) {
-                       BLI_remlink(handlers, handler);
-                       wm_event_free_handler(handler);
+                       if (BLI_findindex(handlers, handler) >= 0) {
+                               BLI_remlink(handlers, handler);
+                               wm_event_free_handler(handler);
+                       }
                }
 
-               
                /* XXX fileread case */
                if(CTX_wm_window(C)==NULL)
                        return action;