Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <b.mont29@gmail.com>2020-03-09 14:06:49 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-09 14:49:04 +0300
commit613148ce5bf887ecf700db0c25aafa45ee9b7a63 (patch)
treeb228c373a2f435650f1f2d0e730a8767f495e520 /source/blender/blenkernel/intern/workspace.c
parent0de5156a24845867bb0d7dd618f5d00b6efd424b (diff)
Cleanup: WorkSpace: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source/blender/blenkernel/intern/workspace.c')
-rw-r--r--source/blender/blenkernel/intern/workspace.c62
1 files changed, 37 insertions, 25 deletions
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.