[Bf-blender-cvs] [4d8980a690e] master: Fix T52640: crash when opening image file browser in some cases.

Brecht Van Lommel noreply at git.blender.org
Wed Sep 6 16:17:49 CEST 2017


Commit: 4d8980a690e87306c3ae2ca8b5fc0b78f025740f
Author: Brecht Van Lommel
Date:   Wed Sep 6 15:56:01 2017 +0200
Branches: master
https://developer.blender.org/rB4d8980a690e87306c3ae2ca8b5fc0b78f025740f

Fix T52640: crash when opening image file browser in some cases.

There was some invalid state in the screen here, some areas had
sa->full set even though no screen was maximized, which then caused
a restore from the wrong (empty) area, which then led to spacedata
being empty and a crash.

This fix properly clears the sa->full after restore, and also fixes
existing .blend files in such an invalid state.

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

M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/screen/screen_edit.c

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

diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index ba985ef5086..f87d04fa0a3 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1671,6 +1671,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
 		}
 	}
+
+	{
+		/* Fix for invalid state of screen due to bug in older versions. */
+		for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
+			for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+				if(sa->full && sc->state == SCREENNORMAL) {
+					sa->full = NULL;
+				}
+			}
+		}
+	}
 }
 
 void do_versions_after_linking_270(Main *main)
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 18372939590..5a3ce70f202 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1894,17 +1894,28 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
 
 	if (sa && sa->full) {
 		/* restoring back to SCREENNORMAL */
-		ScrArea *old;
-
 		sc = sa->full;       /* the old screen to restore */
 		oldscreen = win->screen; /* the one disappearing */
 
 		sc->state = SCREENNORMAL;
 
-		/* find old area */
-		for (old = sc->areabase.first; old; old = old->next)
-			if (old->full) break;
-		if (old == NULL) {
+		/* find old area to restore from */
+		ScrArea *fullsa;
+		for (ScrArea *old = sc->areabase.first; old; old = old->next) {
+			/* area to restore from is always first */
+			if (old->full && !fullsa) {
+				fullsa = old;
+			}
+
+			/* clear full screen state */
+			old->full = NULL;
+			old->flag &= ~AREA_TEMP_INFO;
+		}
+
+		sa->flag &= ~AREA_TEMP_INFO;
+		sa->full = NULL;
+
+		if (fullsa == NULL) {
 			if (G.debug & G_DEBUG)
 				printf("%s: something wrong in areafullscreen\n", __func__);
 			return NULL;
@@ -1917,9 +1928,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
 			}
 		}
 
-		ED_area_data_swap(old, sa);
-		if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
-		old->full = NULL;
+		ED_area_data_swap(fullsa, sa);
 
 		/* animtimer back */
 		sc->animtimer = oldscreen->animtimer;



More information about the Bf-blender-cvs mailing list