[Bf-blender-cvs] [d19ebcb] workspaces: Use new after lib-linking versioning

Julian Eisel noreply at git.blender.org
Sat Dec 31 15:44:36 CET 2016


Commit: d19ebcbe07be890b1ac38807fab5106357e8a359
Author: Julian Eisel
Date:   Sat Dec 31 15:42:42 2016 +0100
Branches: workspaces
https://developer.blender.org/rBd19ebcbe07be890b1ac38807fab5106357e8a359

Use new after lib-linking versioning

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/readfile.h
M	source/blender/blenloader/intern/versioning_270.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2538106..73810b3 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6226,38 +6226,6 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
 	wm->is_interface_locked = 0;
 }
 
-/**
- * \brief Window data compatibility conversion for 2.8
- *
- *  *  Active screen isn't stored directly in window anymore, but in the active workspace.
- *     We already created a new workspace for each screen in blo_do_versions_270, here we need
- *     to find and activate the workspace that contains the active screen of the old file.
- *  *  Active scene isn't stored in screen anymore, but in window.
- *
- * \return if conversion was done.
- */
-static bool lib_link_window_280_conversion(FileData *fd, Main *main, wmWindow *win)
-{
-	if (MAIN_VERSION_ATLEAST(main, 278, 5)) {
-		return false;
-	}
-
-	if (win->screen) {
-		win->screen = newlibadr(fd, NULL, win->screen);
-		win->workspace = BLI_findstring(&main->workspaces, win->screen->id.name + 2,
-		                                offsetof(ID, name) + 2);
-		/* Deprecated from now on! */
-		win->screen = NULL;
-	}
-
-	{
-		const bScreen *screen = BKE_workspace_active_screen_get(win->workspace);
-		win->scene = newlibadr(fd, NULL, screen->scene);
-	}
-
-	return true;
-}
-
 static void lib_link_windowmanager(FileData *fd, Main *main)
 {
 	wmWindowManager *wm;
@@ -6266,10 +6234,9 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
 	for (wm = main->wm.first; wm; wm = wm->id.next) {
 		if (wm->id.tag & LIB_TAG_NEED_LINK) {
 			for (win = wm->windows.first; win; win = win->next) {
-				if (!lib_link_window_280_conversion(fd, main, win)) {
-					win->scene = newlibadr(fd, wm->id.lib, win->scene);
-					win->workspace = newlibadr(fd, wm->id.lib, win->workspace);
-				}
+				win->screen = newlibadr(fd, NULL, win->screen);
+				win->scene = newlibadr(fd, wm->id.lib, win->scene);
+				win->workspace = newlibadr(fd, wm->id.lib, win->workspace);
 			}
 
 			wm->id.tag &= ~LIB_TAG_NEED_LINK;
@@ -6357,8 +6324,8 @@ static void lib_link_screen(FileData *fd, Main *main)
 		if (sc->id.tag & LIB_TAG_NEED_LINK) {
 			id_us_ensure_real(&sc->id);
 
-			/* deprecated now */
-			sc->scene = NULL;
+			/* deprecated, but needed for versioning (will be NULL'ed then) */
+			sc->scene = newlibadr(fd, sc->id.lib, sc->scene);
 
 			sc->animtimer = NULL; /* saved in rare cases */
 			sc->scrubbing = false;
@@ -8467,9 +8434,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 	/* don't forget to set version number in BKE_blender_version.h! */
 }
 
-static void do_versions_after_linking(Main *main)
+static void do_versions_after_linking(FileData *fd, Main *main)
 {
-	UNUSED_VARS(main);
+	blo_do_versions_after_linking_270(fd, main);
 //	printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
 //	       main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
 }
@@ -8681,7 +8648,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
 		blo_split_main(&mainlist, bfd->main);
 		for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) {
 			BLI_assert(mainvar->versionfile != 0);
-			do_versions_after_linking(mainvar);
+			do_versions_after_linking(fd, mainvar);
 		}
 		blo_join_main(&mainlist);
 	}
@@ -10291,7 +10258,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Scene
 		/* We need to split out IDs already existing, or they will go again through do_versions - bad, very bad! */
 		split_main_newid(mainvar, &main_newid);
 
-		do_versions_after_linking(&main_newid);
+		do_versions_after_linking(*fd, &main_newid);
 
 		add_main_to_main(mainvar, &main_newid);
 	}
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 7719aaa..8d1471d 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -169,6 +169,7 @@ void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Mai
 void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main);
 void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *main);
 void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *main);
+void blo_do_versions_after_linking_270(struct FileData *fd, struct Main *main);
 
 #endif
 
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index c47bfff..bf9dfbf 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -196,6 +196,51 @@ static void do_version_bones_super_bbone(ListBase *lb)
 	}
 }
 
+/**
+ * \brief Before lib-link versioning for new workspace design.
+ *
+ * Adds a workspace for each screen of the old file and adds the needed workspace-layout to wrap the screen.
+ * Rest of the conversion is done in #do_version_workspaces_after_lib_link.
+ */
+static void do_version_workspaces_before_lib_link(Main *main)
+{
+	BLI_assert(BLI_listbase_is_empty(&main->workspaces));
+
+	for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
+		WorkSpace *ws = BKE_workspace_add(main, screen->id.name + 2);
+		WorkSpaceLayout *layout = BKE_workspace_layout_add(ws, screen);
+
+		BKE_workspace_active_layout_set(ws, layout);
+
+		/* For compatibility, the workspace should be activated that represents the active
+		 * screen of the old file. This is done in blo_do_versions_after_linking_270. */
+	}
+}
+
+/**
+ * \brief After lib-link versioning for new workspace design.
+ *
+ *  *  Active screen isn't stored directly in window anymore, but in the active workspace.
+ *     We already created a new workspace for each screen in #do_version_workspaces_before_lib_link,
+ *     here we need to find and activate the workspace that contains the active screen of the old file.
+ *  *  Active scene isn't stored in screen anymore, but in window.
+ */
+static void do_version_workspaces_after_lib_link(Main *main)
+{
+	for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
+		for (wmWindow *win = wm->windows.first; win; win = win->next) {
+			bScreen *screen = win->screen;
+
+			win->workspace = BLI_findstring(&main->workspaces, screen->id.name + 2, offsetof(ID, name) + 2);
+			win->scene = screen->scene;
+
+			/* Deprecated from now on! */
+			win->screen = NULL;
+			screen->scene = NULL;
+		}
+	}
+}
+
 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 {
 	if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1520,19 +1565,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 	if (!MAIN_VERSION_ATLEAST(main, 278, 5)) {
 		/* New workspace design */
 		if (!DNA_struct_find(fd->filesdna, "WorkSpace")) {
-			BLI_assert(BLI_listbase_is_empty(&main->workspaces));
-
-			/* Add a workspace for each screen of the old file. */
-			for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
-				WorkSpace *ws = BKE_workspace_add(main, screen->id.name + 2);
-				WorkSpaceLayout *layout = BKE_workspace_layout_add(ws, screen);
-
-				BKE_workspace_active_layout_set(ws, layout);
+			do_version_workspaces_before_lib_link(main);
+		}
+	}
+}
 
-				/* For compatibility, the workspace should be activated that represents the active
-				 * screen of the old file. We can't do this here though since wmWindow.screen
-				 * pointer isn't remapped yet. Done in lib_link_windowmanager instead */
-			}
+void blo_do_versions_after_linking_270(FileData *fd, Main *main)
+{
+	if (!MAIN_VERSION_ATLEAST(main, 278, 5)) {
+		if (!DNA_struct_find(fd->filesdna, "WorkSpace")) {
+			do_version_workspaces_after_lib_link(main);
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list