[Bf-blender-cvs] [f992526] workspaces: File read/write support
Julian Eisel
noreply at git.blender.org
Fri Dec 9 02:42:54 CET 2016
Commit: f99252693bc474a704066979671fc01e8668062d
Author: Julian Eisel
Date: Fri Dec 9 02:42:04 2016 +0100
Branches: workspaces
https://developer.blender.org/rBf99252693bc474a704066979671fc01e8668062d
File read/write support
===================================================================
M source/blender/blenkernel/BKE_blender_version.h
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 4f4787f..207631d 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 278
-#define BLENDER_SUBVERSION 4
+#define BLENDER_SUBVERSION 5
/* Several breakages with 270, e.g. constraint deg vs rad */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 6
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b19334f..ef7ca55 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2731,9 +2731,29 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
direct_link_animdata(fd, cache_file->adt);
}
+/* ************ READ WORKSPACES *************** */
+
+static void lib_link_workspaces(FileData *fd, Main *bmain)
+{
+ /* Note the NULL pointer checks for result of newlibadr. This is needed for reading old files from before the
+ * introduction of workspaces (in do_versioning code we already created workspaces for screens of old file). */
+
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
+ id_us_ensure_real(&workspace->id);
+
+ for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) {
+ bScreen *screen = newlibadr(fd, workspace->id.lib, layout->screen);
+ if (screen) {
+ layout->screen = screen;
+ }
+ }
+ }
+}
+
static void direct_link_workspace(FileData *fd, WorkSpace *ws)
{
- UNUSED_VARS(fd, ws);
+ link_list(fd, &ws->layouts);
+ ws->act_layout = newdataadr(fd, ws->act_layout);
}
/* ************ READ MOTION PATHS *************** */
@@ -5799,11 +5819,13 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
* 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 void lib_link_window_280_conversion(FileData *fd, Main *main, wmWindow *win)
+static bool lib_link_window_280_conversion(FileData *fd, Main *main, wmWindow *win)
{
if (MAIN_VERSION_ATLEAST(main, 278, 5)) {
- return;
+ return false;
}
if (win->screen) {
@@ -5818,6 +5840,8 @@ static void lib_link_window_280_conversion(FileData *fd, Main *main, wmWindow *w
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)
@@ -5828,7 +5852,10 @@ 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) {
- lib_link_window_280_conversion(fd, main, win);
+ 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);
+ }
}
wm->id.tag &= ~LIB_TAG_NEED_LINK;
@@ -8054,6 +8081,7 @@ static void lib_link_all(FileData *fd, Main *main)
lib_link_linestyle(fd, main);
lib_link_gpencil(fd, main);
lib_link_cachefiles(fd, main);
+ lib_link_workspaces(fd, main);
lib_link_mesh(fd, main); /* as last: tpage images with users at zero */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 0583863..8a5dea6b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3681,6 +3681,7 @@ static void write_workspaces(WriteData *wd, ListBase *idbase)
{
for (WorkSpace *ws = idbase->first; ws; ws = ws->id.next) {
writestruct(wd, ID_WS, WorkSpace, 1, ws);
+ writelist(wd, DATA, WorkSpaceLayout, &ws->layouts);
}
}
More information about the Bf-blender-cvs
mailing list