fix for fix, was incorrectly looping over regions.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 27 Apr 2011 14:53:45 +0000 (14:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 27 Apr 2011 14:53:45 +0000 (14:53 +0000)
source/blender/blenloader/intern/readfile.c

index f669b178252aaea4fd444f8b6161c0b459fc1d28..73de7e4c6764635ba0bee50f79b0ba0f6f14aedb 100644 (file)
@@ -11591,26 +11591,31 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        /* put compatibility code here until next subversion bump */
 
        {
-               ARegion *ar;
-               /* screen view2d settings were not properly initialized [#27164] */
+               /* screen view2d settings were not properly initialized [#27164]
+                * v2d->scroll caused the bug but best reset other values too which are in old blend files only.
+                * need to make less ugly - possibly an iterator? */
                bScreen *screen;
                for(screen= main->screen.first; screen; screen= screen->id.next) {
                        ScrArea *sa;
                        /* add regions */
                        for(sa= screen->areabase.first; sa; sa= sa->next) {
-                               SpaceLink *sl;
+                               SpaceLink *sl= sa->spacedata.first;
+                               if(sl->spacetype==SPACE_IMAGE) {
+                                       ARegion *ar;
+                                       for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                                               if(ar->regiontype == RGN_TYPE_WINDOW) {
+                                                       View2D *v2d= &ar->v2d;
+                                                       v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
+                                               }
+                                       }
+                               }
                                for (sl= sa->spacedata.first; sl; sl= sl->next) {
                                        if(sl->spacetype==SPACE_IMAGE) {
-                                               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                                               ARegion *ar;
+                                               for (ar=sl->regionbase.first; ar; ar= ar->next) {
                                                        if(ar->regiontype == RGN_TYPE_WINDOW) {
                                                                View2D *v2d= &ar->v2d;
-                                                               v2d->minzoom= 0;
-                                                               v2d->maxzoom= 0;
-                                                               v2d->scroll= 0; /* cause of bug, but set others just incase */
-                                                               v2d->keeptot= 0;
-                                                               v2d->keepzoom= 0;
-                                                               v2d->keepofs= 0;
-                                                               v2d->align= 0;
+                                                               v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0;
                                                        }
                                                }
                                        }