[Bf-blender-cvs] [3cd1c8ccffe] master: Fix failing asserts in versioning with some pre 2.5 files

Julian Eisel noreply at git.blender.org
Thu Jan 16 17:28:46 CET 2020


Commit: 3cd1c8ccffec516c6ecb6c048dc3aba07d3ad6e5
Author: Julian Eisel
Date:   Thu Jan 16 17:24:28 2020 +0100
Branches: master
https://developer.blender.org/rB3cd1c8ccffec516c6ecb6c048dc3aba07d3ad6e5

Fix failing asserts in versioning with some pre 2.5 files

Old pre 2.5 files may have had non active spaces stored that doen't have
a header. The 2.5 versioning only added headers for active spaces, not
inactive (so invisible) ones.
Newer versioning code assumed there to always be a header though.

Inserted a version patch to make sure there's always a header now.

Fixes error reported to Debian,
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949035.

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

M	source/blender/blenloader/intern/versioning_280.c

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

diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 6d4dd98729a..e746bbf1800 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2828,6 +2828,35 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
 
+    /* Files stored pre 2.5 (possibly re-saved with newer versions) may have non-visible
+     * spaces without a header (visible/active ones are properly versioned).
+     * Multiple version patches below assume there's always a header though. So inserting this
+     * patch in-between older ones to add a header when needed.
+     *
+     * From here on it should be fine to assume there always is a header.
+     */
+    if (!MAIN_VERSION_ATLEAST(bmain, 283, 1)) {
+      for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+          for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+            ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+            ARegion *ar_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER);
+
+            if (!ar_header) {
+              /* Headers should always be first in the region list, except if there's also a
+               * tool-header. These were only introduced in later versions though, so should be
+               * fine to always insert headers first. */
+              BLI_assert(!do_versions_find_region_or_null(regionbase, RGN_TYPE_TOOL_HEADER));
+
+              ARegion *ar = do_versions_add_region(RGN_TYPE_HEADER, "footer for text");
+              ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+              BLI_addhead(regionbase, ar);
+            }
+          }
+        }
+      }
+    }
+
     for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
         for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {



More information about the Bf-blender-cvs mailing list