[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24087] trunk/blender/source/blender/ editors/screen: Bugfix: opening file browser or starting render with mouse outside

Brecht Van Lommel brecht at blender.org
Mon Oct 26 12:43:27 CET 2009


Revision: 24087
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24087
Author:   blendix
Date:     2009-10-26 12:43:27 +0100 (Mon, 26 Oct 2009)

Log Message:
-----------
Bugfix: opening file browser or starting render with mouse outside
of window could crash, these functions relied too much on context.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/screen/screen_edit.c
    trunk/blender/source/blender/editors/screen/screen_intern.h
    trunk/blender/source/blender/editors/screen/screen_ops.c

Modified: trunk/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_edit.c	2009-10-26 11:20:16 UTC (rev 24086)
+++ trunk/blender/source/blender/editors/screen/screen_edit.c	2009-10-26 11:43:27 UTC (rev 24087)
@@ -1404,18 +1404,15 @@
 }
 
 /* this function toggles: if area is full then the parent will be restored */
-void ed_screen_fullarea(bContext *C, ScrArea *sa)
+ScrArea *ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa)
 {
 	bScreen *sc, *oldscreen;
 	
-	if(sa==NULL) {
-		return;
-	}
-	else if(sa->full) {
+	if(sa && sa->full) {
 		short fulltype;
 		
 		sc= sa->full;		/* the old screen to restore */
-		oldscreen= CTX_wm_screen(C);	/* the one disappearing */
+		oldscreen= win->screen;	/* the one disappearing */
 		
 		fulltype = sc->full;
 		
@@ -1455,14 +1452,14 @@
 	else {
 		ScrArea *newa;
 		
-		oldscreen= CTX_wm_screen(C);
+		oldscreen= win->screen;
 
 		/* is there only 1 area? */
 		if(oldscreen->areabase.first==oldscreen->areabase.last) return;
 		
 		oldscreen->full = SCREENFULL;
 		
-		sc= ED_screen_add(CTX_wm_window(C), CTX_data_scene(C), "temp");
+		sc= ED_screen_add(win, oldscreen->scene, "temp");
 		sc->full = SCREENFULL; // XXX
 		
 		/* timer */
@@ -1470,9 +1467,14 @@
 		oldscreen->animtimer= NULL;
 		
 		/* returns the top small area */
-		newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
+		newa= area_split(win, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
 		ED_area_newspace(C, newa, SPACE_INFO);
 
+		/* use random area when we have no active one, e.g. when the
+		   mouse is outside of the window and we open a file browser */
+		if(!sa)
+			sa= oldscreen->areabase.first;
+
 		/* copy area */
 		newa= newa->prev;
 		area_copy_data(newa, sa, 1);	/* 1 = swap spacelist */
@@ -1489,30 +1491,33 @@
 
 	/* XXX retopo_force_update(); */
 
+	return sc->areabase.first;
 }
 
 int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
 {
-	if(sa==NULL)
-		return 0;
-	
-	if(sa->full==0)
-		ed_screen_fullarea(C, sa);
+	wmWindow *win= CTX_wm_window(C);
+	ScrArea *newsa= NULL;
 
-	/* CTX_wm_area(C) is new area */
-	ED_area_newspace(C, CTX_wm_area(C), type);
+	if(!sa || sa->full==0)
+		newsa= ed_screen_fullarea(C, win, sa);
+	else
+		newsa= sa;
+
+	ED_area_newspace(C, newsa, type);
 	
 	return 1;
 }
 
 void ED_screen_full_prevspace(bContext *C)
 {
+	wmWindow *win= CTX_wm_window(C);
 	ScrArea *sa= CTX_wm_area(C);
 	
 	ED_area_prevspace(C);
 	
 	if(sa->full)
-		ed_screen_fullarea(C, sa);
+		ed_screen_fullarea(C, win, sa);
 }
 
 /* redraws: uses defines from stime->redraws 

Modified: trunk/blender/source/blender/editors/screen/screen_intern.h
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_intern.h	2009-10-26 11:20:16 UTC (rev 24086)
+++ trunk/blender/source/blender/editors/screen/screen_intern.h	2009-10-26 11:43:27 UTC (rev 24087)
@@ -51,7 +51,7 @@
 
 AZone		*is_in_area_actionzone(ScrArea *sa, int x, int y);
 
-void		ed_screen_fullarea(bContext *C, ScrArea *sa);
+ScrArea		*ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa);
 
 /* screen_context.c */
 void ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);

Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c	2009-10-26 11:20:16 UTC (rev 24086)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c	2009-10-26 11:43:27 UTC (rev 24087)
@@ -1577,7 +1577,7 @@
 /* function to be called outside UI context, or for redo */
 static int screen_full_area_exec(bContext *C, wmOperator *op)
 {
-	ed_screen_fullarea(C, CTX_wm_area(C));
+	ed_screen_fullarea(C, CTX_wm_window(C), CTX_wm_area(C));
 	return OPERATOR_FINISHED;
 }
 
@@ -2576,6 +2576,7 @@
 /* new window uses x,y to set position */
 static void screen_set_image_output(bContext *C, int mx, int my)
 {
+	wmWindow *win= CTX_wm_window(C);
 	Scene *scene= CTX_data_scene(C);
 	ScrArea *sa= NULL;
 	SpaceImage *sima;
@@ -2592,8 +2593,8 @@
 		if(sizey < 256) sizey= 256;
 		
 		/* XXX some magic to calculate postition */
-		rect.xmin= mx + CTX_wm_window(C)->posx - sizex/2;
-		rect.ymin= my + CTX_wm_window(C)->posy - sizey/2;
+		rect.xmin= mx + win->posx - sizex/2;
+		rect.ymin= my + win->posy - sizey/2;
 		rect.xmax= rect.xmin + sizex;
 		rect.ymax= rect.ymin + sizey;
 		
@@ -2645,7 +2646,7 @@
 		if(sa->full) {
 			sima->flag |= SI_FULLWINDOW|SI_PREVSPACE;
 			
-//			ed_screen_fullarea(C, sa);
+//			ed_screen_fullarea(C, win, sa);
 		}
 //	}
 	
@@ -3015,6 +3016,7 @@
 
 static int render_view_cancel_exec(bContext *C, wmOperator *unused)
 {
+	wmWindow *win= CTX_wm_window(C);
 	ScrArea *sa= CTX_wm_area(C);
 	SpaceImage *sima= sa->spacedata.first;
 	
@@ -3038,7 +3040,7 @@
 	}
 	else if(sima->flag & SI_FULLWINDOW) {
 		sima->flag &= ~SI_FULLWINDOW;
-		ed_screen_fullarea(C, sa);
+		ed_screen_fullarea(C, win, sa);
 		return OPERATOR_FINISHED;
 	}
 





More information about the Bf-blender-cvs mailing list