diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 14:06:49 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 14:49:04 +0300 |
commit | 613148ce5bf887ecf700db0c25aafa45ee9b7a63 (patch) | |
tree | b228c373a2f435650f1f2d0e730a8767f495e520 /source/blender/blenkernel/intern | |
parent | 0de5156a24845867bb0d7dd618f5d00b6efd424b (diff) |
Cleanup: WorkSpace: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/idtype.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_delete.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/workspace.c | 62 |
3 files changed, 39 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index a7274fbc23d..0e72b20e035 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -85,7 +85,7 @@ static void id_type_init(void) // INIT_TYPE(ID_PAL); // INIT_TYPE(ID_PC); // INIT_TYPE(ID_CF); - // INIT_TYPE(ID_WS); + INIT_TYPE(ID_WS); INIT_TYPE(ID_LP); #undef INIT_TYPE diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index 6a017d5a8d7..f9df36a71cc 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -241,7 +241,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag)) BKE_cachefile_free((CacheFile *)id); break; case ID_WS: - BKE_workspace_free((WorkSpace *)id); + BLI_assert(0); break; } } diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index 6e923822f7d..8fff2e60594 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -26,8 +26,11 @@ #include "BLI_string_utils.h" #include "BLI_listbase.h" +#include "BLT_translation.h" + #include "BKE_global.h" #include "BKE_idprop.h" +#include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_scene.h" @@ -45,6 +48,39 @@ #include "MEM_guardedalloc.h" /* -------------------------------------------------------------------- */ + +static void workspace_free_data(ID *id) +{ + WorkSpace *workspace = (WorkSpace *)id; + + BKE_workspace_relations_free(&workspace->hook_layout_relations); + + BLI_freelistN(&workspace->owner_ids); + BLI_freelistN(&workspace->layouts); + + while (!BLI_listbase_is_empty(&workspace->tools)) { + BKE_workspace_tool_remove(workspace, workspace->tools.first); + } + + MEM_SAFE_FREE(workspace->status_text); +} + +IDTypeInfo IDType_ID_WS = { + .id_code = ID_WS, + .id_filter = FILTER_ID_WS, + .main_listbase_index = INDEX_ID_WS, + .struct_size = sizeof(WorkSpace), + .name = "WorkSpace", + .name_plural = "workspaces", + .translation_context = BLT_I18NCONTEXT_ID_WORKSPACE, + .flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_MAKELOCAL, + + .init_data = NULL, + .copy_data = NULL, + .free_data = workspace_free_data, + .make_local = NULL, +}; + /** \name Internal Utils * \{ */ @@ -151,32 +187,8 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name) } /** - * The function that actually frees the workspace data (not workspace itself). - * It shouldn't be called directly, instead #BKE_workspace_remove should be, - * which calls this through #BKE_id_free then. - * - * Should something like a bke_internal.h be added, this should go there! - */ -void BKE_workspace_free(WorkSpace *workspace) -{ - BKE_workspace_relations_free(&workspace->hook_layout_relations); - - BLI_freelistN(&workspace->owner_ids); - BLI_freelistN(&workspace->layouts); - - while (!BLI_listbase_is_empty(&workspace->tools)) { - BKE_workspace_tool_remove(workspace, workspace->tools.first); - } - - if (workspace->status_text) { - MEM_freeN(workspace->status_text); - workspace->status_text = NULL; - } -} - -/** * Remove \a workspace by freeing itself and its data. This is a higher-level wrapper that - * calls #BKE_workspace_free (through #BKE_id_free) to free the workspace data, and frees + * calls #workspace_free_data (through #BKE_id_free) to free the workspace data, and frees * other data-blocks owned by \a workspace and its layouts (currently that is screens only). * * Always use this to remove (and free) workspaces. Don't free non-ID workspace members here. |