From dee5af12e3327dd2dcd80eaef15c44756eb42315 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 19 May 2005 15:47:42 +0000 Subject: Back to the Future bugfix! When a new space (window) type gets added, older Blender binaries will crash on reading files saved with such spaces. This breaks the so nice upward compility on files... With addition of SpaceTime I got an occasion to verify & fix that. If Blender detects a non-existant space it will degrade it to a 3D window now. Tested on a full 2.34 compile. --- source/blender/src/spacetypes.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/blender/src/spacetypes.c b/source/blender/src/spacetypes.c index 2b7b8de4dce..6509aee6982 100644 --- a/source/blender/src/spacetypes.c +++ b/source/blender/src/spacetypes.c @@ -43,6 +43,7 @@ #include "BIF_gl.h" #include "BIF_mywindow.h" #include "BIF_screen.h" +#include "BIF_space.h" #include "BIF_spacetypes.h" /***/ @@ -75,11 +76,11 @@ void spacetype_set_winfuncs(SpaceType *st, SpaceDrawFP draw, SpaceChangeFP chang st->winhandle= handle; } - /***/ + /* gets SpaceType struct, but also has patch to initialize unknown spacetypes */ -static SpaceType *spacetype_from_code(int spacecode) +static SpaceType *spacetype_from_area(ScrArea *area) { - switch (spacecode) { + switch (area->spacetype) { case SPACE_ACTION: return spaceaction_get_type(); case SPACE_BUTS: return spacebuts_get_type(); case SPACE_FILE: return spacefile_get_type(); @@ -96,13 +97,15 @@ static SpaceType *spacetype_from_code(int spacecode) case SPACE_VIEW3D: return spaceview3d_get_type(); case SPACE_TIME: return spacetime_get_type(); default: + newspace(area, SPACE_VIEW3D); + return spaceview3d_get_type(); return NULL; } } void scrarea_do_windraw(ScrArea *area) { - SpaceType *st= spacetype_from_code(area->spacetype); + SpaceType *st= spacetype_from_area(area); areawinset(area->win); @@ -118,7 +121,7 @@ void scrarea_do_windraw(ScrArea *area) } void scrarea_do_winchange(ScrArea *area) { - SpaceType *st= spacetype_from_code(area->spacetype); + SpaceType *st= spacetype_from_area(area); areawinset(area->win); @@ -133,7 +136,7 @@ void scrarea_do_winchange(ScrArea *area) } void scrarea_do_winhandle(ScrArea *area, BWinEvent *evt) { - SpaceType *st= spacetype_from_code(area->spacetype); + SpaceType *st= spacetype_from_area(area); areawinset(area->win); -- cgit v1.2.3