[Bf-blender-cvs] [f2dc78f13fb] master: App Template: match screen names to workspaces

Campbell Barton noreply at git.blender.org
Tue Apr 23 00:52:45 CEST 2019


Commit: f2dc78f13fb7aa7af02828ec42d8ecf030d7b2a5
Author: Campbell Barton
Date:   Tue Apr 23 08:49:10 2019 +1000
Branches: master
https://developer.blender.org/rBf2dc78f13fb7aa7af02828ec42d8ecf030d7b2a5

App Template: match screen names to workspaces

Doing this makes versioning workspace screens simpler.

This was already done for the default startup file.

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

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

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

diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index a89b9a034f0..c5263708f43 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -144,6 +144,11 @@ static ID *rename_id_for_versioning(Main *bmain,
  * This function can be emptied each time the startup.blend is updated. */
 void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 {
+  /* For all builtin templates shipped with Blender. */
+  const bool builtin_template =
+      (!app_template ||
+       STR_ELEM(app_template, "2D_Animation", "Sculpting", "VFX", "Video_Editing"));
+
   /* For all startup.blend files. */
   for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
     for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -191,31 +196,29 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
     }
   }
 
-  if (app_template == NULL) {
+  if (builtin_template) {
     /* Name all screens by their workspaces (avoids 'Default.###' names). */
-    {
-      /* Default only has one window. */
-      wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
-      for (WorkSpace *workspace = bmain->workspaces.first; workspace;
-           workspace = workspace->id.next) {
-        WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook,
-                                                                              workspace);
-        bScreen *screen = layout->screen;
-        BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
-        BLI_libblock_ensure_unique_name(bmain, screen->id.name);
-      }
+    /* Default only has one window. */
+    wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
+    for (WorkSpace *workspace = bmain->workspaces.first; workspace;
+         workspace = workspace->id.next) {
+      WorkSpaceLayout *layout = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook,
+                                                                            workspace);
+      bScreen *screen = layout->screen;
+      BLI_strncpy(screen->id.name + 2, workspace->id.name + 2, sizeof(screen->id.name) - 2);
+      BLI_libblock_ensure_unique_name(bmain, screen->id.name);
     }
+  }
 
-    {
-      /* 'UV Editing' should use UV mode. */
-      bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
-      for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
-        for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
-          if (sl->spacetype == SPACE_IMAGE) {
-            SpaceImage *sima = (SpaceImage *)sl;
-            if (sima->mode == SI_MODE_VIEW) {
-              sima->mode = SI_MODE_UV;
-            }
+  if (app_template == NULL) {
+    /* 'UV Editing' should use UV mode. */
+    bScreen *screen = BLI_findstring(&bmain->screens, "UV Editing", offsetof(ID, name) + 2);
+    for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+      for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+        if (sl->spacetype == SPACE_IMAGE) {
+          SpaceImage *sima = (SpaceImage *)sl;
+          if (sima->mode == SI_MODE_VIEW) {
+            sima->mode = SI_MODE_UV;
           }
         }
       }
@@ -266,11 +269,6 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
     }
   }
 
-  /* For all builtin templates shipped with Blender. */
-  bool builtin_template = (!app_template || STREQ(app_template, "2D_Animation") ||
-                           STREQ(app_template, "Sculpting") || STREQ(app_template, "VFX") ||
-                           STREQ(app_template, "Video_Editing"));
-
   if (builtin_template) {
     /* Clear all tools to use default options instead, ignore the tool saved in the file. */
     for (WorkSpace *workspace = bmain->workspaces.first; workspace;



More information about the Bf-blender-cvs mailing list