Cleanup: WorkSpace: Move to IDTypeInfo and remove unused BKE API.
This commit is contained in:
parent
0de5156a24
commit
613148ce5b
|
@ -158,7 +158,7 @@ extern IDTypeInfo IDType_ID_WM;
|
|||
// extern IDTypeInfo IDType_ID_PAL;
|
||||
// extern IDTypeInfo IDType_ID_PC;
|
||||
// extern IDTypeInfo IDType_ID_CF;
|
||||
// extern IDTypeInfo IDType_ID_WS;
|
||||
extern IDTypeInfo IDType_ID_WS;
|
||||
extern IDTypeInfo IDType_ID_LP;
|
||||
|
||||
/* ********** Helpers/Utils API. ********** */
|
||||
|
|
|
@ -35,7 +35,6 @@ struct bToolRef;
|
|||
/* Create, delete, init */
|
||||
|
||||
struct WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
|
||||
void BKE_workspace_free(struct WorkSpace *workspace);
|
||||
void BKE_workspace_remove(struct Main *bmain, struct WorkSpace *workspace);
|
||||
|
||||
struct WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct Main *bmain);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* \{ */
|
||||
|
||||
|
@ -150,33 +186,9 @@ WorkSpace *BKE_workspace_add(Main *bmain, const char *name)
|
|||
return new_workspace;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue