Fix preview do_version bug (causing region type missing errors)
authorMartin Poirier <theeth@yahoo.com>
Sat, 19 Dec 2009 22:40:45 +0000 (22:40 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sat, 19 Dec 2009 22:40:45 +0000 (22:40 +0000)
The missing region was added to the wrong region base.

Bump the subversion, new code to fix wrong region layouts saved in previous subversion and correct all old files correctly.

source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/readfile.c

index 8a7f4da8cbf785bdab807f44a8f59d6b6ceae71d..8e7e698a9863bda83624f29179f2935eeed7b884 100644 (file)
@@ -43,7 +43,7 @@ struct bContext;
 struct ReportList;
 
 #define BLENDER_VERSION                        250
 struct ReportList;
 
 #define BLENDER_VERSION                        250
-#define BLENDER_SUBVERSION             10
+#define BLENDER_SUBVERSION             11
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 9548db3278a5dc93d642bff54c34da76123a96d3..24e5cb67d89682ff430749b06068c4e71ee221db 100644 (file)
 #include "BKE_report.h"
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
 #include "BKE_report.h"
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
+#include "BKE_screen.h"
 #include "BKE_softbody.h"      // sbNew()
 #include "BKE_bullet.h"                // bsbNew()
 #include "BKE_sequencer.h"
 #include "BKE_softbody.h"      // sbNew()
 #include "BKE_bullet.h"                // bsbNew()
 #include "BKE_sequencer.h"
@@ -10194,27 +10195,75 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 
        if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10))
        {
 
        if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10))
        {
-               {
-                       Object *ob;
-                       
-                       /* properly initialise hair clothsim data on old files */
-                       for(ob = main->object.first; ob; ob = ob->id.next) {
-                               ModifierData *md;
-                               for(md= ob->modifiers.first; md; md= md->next) {
-                                       if (md->type == eModifierType_Cloth) {
-                                               ClothModifierData *clmd = (ClothModifierData *)md;
-                                               if (clmd->sim_parms->velocity_smooth < 0.01f)
-                                                       clmd->sim_parms->velocity_smooth = 0.f;
+               Object *ob;
+
+               /* properly initialise hair clothsim data on old files */
+               for(ob = main->object.first; ob; ob = ob->id.next) {
+                       ModifierData *md;
+                       for(md= ob->modifiers.first; md; md= md->next) {
+                               if (md->type == eModifierType_Cloth) {
+                                       ClothModifierData *clmd = (ClothModifierData *)md;
+                                       if (clmd->sim_parms->velocity_smooth < 0.01f)
+                                               clmd->sim_parms->velocity_smooth = 0.f;
+                               }
+                       }
+               }
+       }
+
+       /* fix bad area setup in subversion 10 */
+       if (main->versionfile == 250 && main->subversionfile == 10)
+       {
+               /* fix for new view type in sequencer */
+               bScreen *screen;
+               ScrArea *sa;
+               SpaceLink *sl;
+
+
+               /* remove all preview window in wrong spaces */
+               for(screen= main->screen.first; screen; screen= screen->id.next) {
+                       for(sa= screen->areabase.first; sa; sa= sa->next) {
+                               for(sl= sa->spacedata.first; sl; sl= sl->next) {
+                                       if(sl->spacetype!=SPACE_SEQ) {
+                                               ARegion *ar;
+
+                                               for( ar = sl->regionbase.first; ar; ar = ar->next) {
+                                                       if (ar->regiontype == RGN_TYPE_PREVIEW)
+                                                               break;
+                                               }
+
+                                               if (ar) {
+                                                       SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ);
+                                                       BKE_area_region_free(st, ar);
+                                                       BLI_freelinkN(&sl->regionbase, ar);
+                                               }
+                                       }
+                               }
+                               if(sa->spacetype!=SPACE_SEQ) {
+                                       ARegion *ar;
+
+                                       for( ar = sa->regionbase.first; ar; ar = ar->next) {
+                                               if (ar->regiontype == RGN_TYPE_PREVIEW)
+                                                       break;
+                                       }
+
+                                       if (ar) {
+                                               SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ);
+                                               BKE_area_region_free(st, ar);
+                                               BLI_freelinkN(&sa->regionbase, ar);
                                        }
                                }
                        }
                }
                                        }
                                }
                        }
                }
+       }
+
+       if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11))
+       {
                {
                        /* fix for new view type in sequencer */
                        bScreen *screen;
                        ScrArea *sa;
                        SpaceLink *sl;
                {
                        /* fix for new view type in sequencer */
                        bScreen *screen;
                        ScrArea *sa;
                        SpaceLink *sl;
-                       
+
 
                        for(screen= main->screen.first; screen; screen= screen->id.next) {
                                for(sa= screen->areabase.first; sa; sa= sa->next) {
 
                        for(screen= main->screen.first; screen; screen= screen->id.next) {
                                for(sa= screen->areabase.first; sa; sa= sa->next) {
@@ -10222,12 +10271,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                if(sl->spacetype==SPACE_SEQ) {
                                                        ARegion *ar;
                                                        ARegion *ar_main;
                                                if(sl->spacetype==SPACE_SEQ) {
                                                        ARegion *ar;
                                                        ARegion *ar_main;
-                                                       ListBase *lb = &sa->regionbase;
+                                                       ListBase *lb = &sl->regionbase;
                                                        SpaceSeq *sseq = (SpaceSeq *)sl;
 
                                                        if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE;
                                                        if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
                                                        SpaceSeq *sseq = (SpaceSeq *)sl;
 
                                                        if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE;
                                                        if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
-                                                       
+
                                                        ar_main = (ARegion*)lb->first;
                                                        for (; ar_main; ar_main = ar_main->next) {
                                                                if (ar_main->regiontype == RGN_TYPE_WINDOW)
                                                        ar_main = (ARegion*)lb->first;
                                                        for (; ar_main; ar_main = ar_main->next) {
                                                                if (ar_main->regiontype == RGN_TYPE_WINDOW)