[Bf-blender-cvs] [82ba89b] blender2.8: Fix T49961: Blender 2.8 Crashes on saving an image

Julian Eisel noreply at git.blender.org
Thu Nov 10 20:41:43 CET 2016


Commit: 82ba89b042e7067d989daa0fcb414bdc9e31c276
Author: Julian Eisel
Date:   Thu Nov 10 19:56:52 2016 +0100
Branches: blender2.8
https://developer.blender.org/rB82ba89b042e7067d989daa0fcb414bdc9e31c276

Fix T49961: Blender 2.8 Crashes on saving an image

Caused by 4811b2d3565cf which caused the event handler hack that is used to fire up the file browser from other operators to fail. Basically the context from before the file browser is opened gets stored and used later for executing the actual file read/write operation (in this case, saving image). This context storage is cleared when exiting an editor since 4811b2d3565cf, which is technically correct, but causes usage of NULLed context data in this case, because the file browser is exite [...]

For now I solved this by moving the fileselect handler to list of normal handlers, instead of modal ones. 4811b2d3565cf only touches list of modal handlers so we avoid the crash. Ideally we'd completely refactor how the file browser opening works to get rid of these event handler hacks.

Note that I wouldn't be suprised if this causes other regressions, but I couldn't find one so worth a try.

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

M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/wm_event_system.h

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

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index b15b47c..cadc3ac 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2641,7 +2641,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
 	wmWindow *win = CTX_wm_window(C);
 
 	/* only allow 1 file selector open per window */
-	for (handler = win->modalhandlers.first; handler; handler = handlernext) {
+	for (handler = win->handlers.first; handler; handler = handlernext) {
 		handlernext = handler->next;
 		
 		if (handler->type == WM_HANDLER_FILESELECT) {
@@ -2655,7 +2655,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
 
 					if (sfile->op == handler->op) {
 						CTX_wm_area_set(C, sa);
-						wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
+						wm_handler_fileselect_do(C, &win->handlers, handler, EVT_FILESELECT_CANCEL);
 						break;
 					}
 				}
@@ -2663,7 +2663,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
 
 			/* if not found we stop the handler without changing the screen */
 			if (!sa)
-				wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
+				wm_handler_fileselect_do(C, &win->handlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
 		}
 	}
 	
@@ -2674,7 +2674,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
 	handler->op_area = CTX_wm_area(C);
 	handler->op_region = CTX_wm_region(C);
 	
-	BLI_addhead(&win->modalhandlers, handler);
+	BLI_addhead(&win->handlers, handler);
 	
 	/* check props once before invoking if check is available
 	 * ensures initial properties are valid */
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index abab7c5..2f7ebbc 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -52,7 +52,7 @@ typedef struct wmEventHandler {
 	wmKeyMap *keymap;                   /* pointer to builtin/custom keymaps */
 	const rcti *bblocal, *bbwin;              /* optional local and windowspace bb */
 
-	/* modal operator handler */
+	/* modal operator handler and WM_HANDLER_FILESELECT */
 	wmOperator *op;                     /* for derived/modal handlers */
 	struct ScrArea *op_area;            /* for derived/modal handlers */
 	struct ARegion *op_region;          /* for derived/modal handlers */




More information about the Bf-blender-cvs mailing list