From 62e532785dfd5bd25fb6b1269ec41ea81a32c4c9 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 30 Oct 2020 16:32:19 +0100 Subject: Refactor: move WorkSpace .blend I/O to IDTypeInfo callbacks --- source/blender/blenloader/intern/readfile.c | 85 ++-------------------------- source/blender/blenloader/intern/writefile.c | 19 +------ 2 files changed, 7 insertions(+), 97 deletions(-) (limited to 'source/blender/blenloader/intern') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6f305a5613f..29ed66c5080 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2569,69 +2569,6 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas /** \name Read ID: WorkSpace * \{ */ -static void lib_link_workspaces(BlendLibReader *reader, WorkSpace *workspace) -{ - ID *id = (ID *)workspace; - - /* Restore proper 'parent' pointers to relevant data, and clean up unused/invalid entries. */ - LISTBASE_FOREACH_MUTABLE (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) { - relation->parent = NULL; - LISTBASE_FOREACH (wmWindowManager *, wm, &reader->main->wm) { - LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { - if (win->winid == relation->parentid) { - relation->parent = win->workspace_hook; - } - } - } - if (relation->parent == NULL) { - BLI_freelinkN(&workspace->hook_layout_relations, relation); - } - } - - LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) { - BLO_read_id_address(reader, id->lib, &layout->screen); - - if (layout->screen) { - if (ID_IS_LINKED(id)) { - layout->screen->winid = 0; - if (layout->screen->temp) { - /* delete temp layouts when appending */ - BKE_workspace_layout_remove(reader->main, workspace, layout); - } - } - } - else { - /* If we're reading a layout without screen stored, it's useless and we shouldn't keep it - * around. */ - BKE_workspace_layout_remove(reader->main, workspace, layout); - } - } -} - -static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace) -{ - BLO_read_list(reader, &workspace->layouts); - BLO_read_list(reader, &workspace->hook_layout_relations); - BLO_read_list(reader, &workspace->owner_ids); - BLO_read_list(reader, &workspace->tools); - - LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) { - /* parent pointer does not belong to workspace data and is therefore restored in lib_link step - * of window manager.*/ - BLO_read_data_address(reader, &relation->value); - } - - LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { - tref->runtime = NULL; - BLO_read_data_address(reader, &tref->properties); - IDP_BlendDataRead(reader, &tref->properties); - } - - workspace->status_text = NULL; - - id_us_ensure_real(&workspace->id); -} - static void lib_link_workspace_instance_hook(BlendLibReader *reader, WorkSpaceInstanceHook *hook, ID *id) @@ -5510,8 +5447,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * direct_link_library(fd, (Library *)id, main); break; case ID_WS: - direct_link_workspace(&reader, (WorkSpace *)id); - break; case ID_PA: case ID_GR: case ID_ME: @@ -6132,10 +6067,6 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_WM: lib_link_windowmanager(&reader, (wmWindowManager *)id); break; - case ID_WS: - /* Could we skip WS in undo case? */ - lib_link_workspaces(&reader, (WorkSpace *)id); - break; case ID_SCE: lib_link_scene(&reader, (Scene *)id); break; @@ -6149,6 +6080,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_LI: lib_link_library(&reader, (Library *)id); /* Only init users. */ break; + case ID_WS: case ID_SCR: case ID_PA: case ID_GR: @@ -7033,13 +6965,6 @@ static void expand_scene(BlendExpander *expander, Scene *sce) } } -static void expand_workspace(BlendExpander *expander, WorkSpace *workspace) -{ - LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { - BLO_expand(expander, BKE_workspace_layout_screen_get(layout)); - } -} - /** * Set the callback func used over all ID data found by \a BLO_expand_main func. * @@ -7092,9 +7017,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_IP: expand_ipo(&expander, (Ipo *)id); /* XXX deprecated - old animation system */ break; - case ID_WS: - expand_workspace(&expander, (WorkSpace *)id); - break; default: break; } @@ -8230,6 +8152,11 @@ bool BLO_read_lib_is_undo(BlendLibReader *reader) return reader->fd->memfile != NULL; } +Main *BLO_read_lib_get_main(BlendLibReader *reader) +{ + return reader->main; +} + void BLO_expand_id(BlendExpander *expander, ID *id) { expand_doit(expander->fd, expander->main, id); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index bcfc5778f1d..835e2f92c7c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1662,21 +1662,6 @@ static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const } } -static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address) -{ - BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id); - BKE_id_blend_write(writer, &workspace->id); - BLO_write_struct_list(writer, WorkSpaceLayout, &workspace->layouts); - BLO_write_struct_list(writer, WorkSpaceDataRelation, &workspace->hook_layout_relations); - BLO_write_struct_list(writer, wmOwnerID, &workspace->owner_ids); - BLO_write_struct_list(writer, bToolRef, &workspace->tools); - LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { - if (tref->properties) { - IDP_BlendWrite(writer, tref->properties); - } - } -} - /* Keep it last of write_foodata functions. */ static void write_libraries(WriteData *wd, Main *main) { @@ -1938,15 +1923,13 @@ static bool write_file_handle(Main *mainvar, case ID_WM: write_windowmanager(&writer, (wmWindowManager *)id_buffer, id); break; - case ID_WS: - write_workspace(&writer, (WorkSpace *)id_buffer, id); - break; case ID_SCE: write_scene(&writer, (Scene *)id_buffer, id); break; case ID_OB: write_object(&writer, (Object *)id_buffer, id); break; + case ID_WS: case ID_SCR: case ID_PA: case ID_GR: -- cgit v1.2.3