Fix [#20397] Saving with F2 on multiple windows layout crashes
authorMatt Ebb <matt@mke3.net>
Thu, 17 Dec 2009 10:01:08 +0000 (10:01 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 17 Dec 2009 10:01:08 +0000 (10:01 +0000)
source/blender/editors/screen/screen_edit.c
source/blender/windowmanager/intern/wm_event_system.c

index 9c581527e4c97b6665f0bcd43c3b4526b0eff011..0c690452d8a3d957bb739d72a010b6921b3254b6 100644 (file)
@@ -1487,9 +1487,11 @@ ScrArea *ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa)
                
                oldscreen= win->screen;
 
-               /* is there only 1 area? */
+               /* nothing wrong with having only 1 area, as far as I can see...
+               // is there only 1 area?
                if(oldscreen->areabase.first==oldscreen->areabase.last)
                        return NULL;
+               */
                
                oldscreen->full = SCREENFULL;
                BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name+2, "temp");
index 710f9897c94f0dace6e8013f203e1d055c8e95b3..ccc020827c5c6a8b0ef1e8a98378bb283e413078 100644 (file)
@@ -997,13 +997,24 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
                case EVT_FILESELECT_OPEN: 
                case EVT_FILESELECT_FULL_OPEN: 
                        {       
+                               ScrArea *sa;
+                               
+                               /* sa can be null when window A is active, but mouse is over window B */
+                               /* in this case, open file select in original window A */
+                               if (handler->op_area == NULL) {
+                                       bScreen *screen = CTX_wm_screen(C);
+                                       sa = (ScrArea *)screen->areabase.first;
+                               } else
+                                       sa = handler->op_area;
+                                       
                                if(event->val==EVT_FILESELECT_OPEN)
-                                       ED_area_newspace(C, handler->op_area, SPACE_FILE);
+                                       ED_area_newspace(C, sa, SPACE_FILE);
                                else
-                                       ED_screen_full_newspace(C, handler->op_area, SPACE_FILE);
+                                       ED_screen_full_newspace(C, sa, SPACE_FILE);     /* sets context */
                                
                                /* settings for filebrowser, sfile is not operator owner but sends events */
-                               sfile= (SpaceFile*)CTX_wm_space_data(C);
+                               sa = CTX_wm_area(C);
+                               sfile= (SpaceFile*)sa->spacedata.first;
                                sfile->op= handler->op;
 
                                ED_fileselect_set_params(sfile);