[Bf-blender-cvs] [0de1df4] master: Fix T37756: file > open with file selector already open not restoring screen correctly.

Brecht Van Lommel noreply at git.blender.org
Wed Feb 26 19:51:08 CET 2014


Commit: 0de1df49e1f4465d4095e1d5b22b71836cdd6226
Author: Brecht Van Lommel
Date:   Wed Feb 26 19:50:12 2014 +0100
https://developer.blender.org/rB0de1df49e1f4465d4095e1d5b22b71836cdd6226

Fix T37756: file > open with file selector already open not restoring screen correctly.

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

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

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

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 3298a78..6a70be3 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1644,19 +1644,14 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
 	return WM_HANDLER_BREAK;
 }
 
-/* fileselect handlers are only in the window queue, so it's save to switch screens or area types */
-static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event)
+/* fileselect handlers are only in the window queue, so it's safe to switch screens or area types */
+static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHandler *handler, int val)
 {
 	wmWindowManager *wm = CTX_wm_manager(C);
 	SpaceFile *sfile;
 	int action = WM_HANDLER_CONTINUE;
-	
-	if (event->type != EVT_FILESELECT)
-		return action;
-	if (handler->op != (wmOperator *)event->customdata)
-		return action;
-	
-	switch (event->val) {
+
+	switch (val) {
 		case EVT_FILESELECT_OPEN: 
 		case EVT_FILESELECT_FULL_OPEN: 
 		{
@@ -1672,7 +1667,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
 				sa = handler->op_area;
 			}
 					
-			if (event->val == EVT_FILESELECT_OPEN) {
+			if (val == EVT_FILESELECT_OPEN) {
 				ED_area_newspace(C, sa, SPACE_FILE);     /* 'sa' is modified in-place */
 			}
 			else {
@@ -1703,7 +1698,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
 			/* remlink now, for load file case before removing*/
 			BLI_remlink(handlers, handler);
 				
-			if (event->val != EVT_FILESELECT_EXTERNAL_CANCEL) {
+			if (val != EVT_FILESELECT_EXTERNAL_CANCEL) {
 				if (screen != handler->filescreen) {
 					ED_screen_full_prevspace(C, CTX_wm_area(C));
 				}
@@ -1716,7 +1711,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
 
 			/* needed for uiPupMenuReports */
 
-			if (event->val == EVT_FILESELECT_EXEC) {
+			if (val == EVT_FILESELECT_EXEC) {
 				int retval;
 
 				if (handler->op->type->flag & OPTYPE_UNDO)
@@ -1793,6 +1788,18 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
 	return action;
 }
 
+static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event)
+{
+	int action = WM_HANDLER_CONTINUE;
+	
+	if (event->type != EVT_FILESELECT)
+		return action;
+	if (handler->op != (wmOperator *)event->customdata)
+		return action;
+	
+	return wm_handler_fileselect_do(C, handlers, handler, event->val);
+}
+
 static bool handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
 {
 	if (handler->bbwin) {
@@ -2409,10 +2416,25 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
 		handlernext = handler->next;
 		
 		if (handler->type == WM_HANDLER_FILESELECT) {
-			if (handler->op)
-				WM_operator_free(handler->op);
-			BLI_remlink(&win->modalhandlers, handler);
-			wm_event_free_handler(handler);
+			bScreen *screen = CTX_wm_screen(C);
+			ScrArea *sa;
+
+			/* find the area with the file selector for this handler */
+			for (sa = screen->areabase.first; sa; sa = sa->next) {
+				if (sa->spacetype == SPACE_FILE) {
+					SpaceFile *sfile = sa->spacedata.first;
+
+					if (sfile->op == handler->op) {
+						CTX_wm_area_set(C, sa);
+						wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
+						break;
+					}
+				}
+			}
+
+			/* 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);
 		}
 	}




More information about the Bf-blender-cvs mailing list