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:
authorCampbell Barton <ideasman42@gmail.com>2018-09-27 04:20:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-27 04:20:27 +0300
commited83075402c2b6df757857ead0c93bb8bf14093d (patch)
treebfb38e533d018a02bc345a58c4db6e3a041a1191 /source/blender/blenkernel
parent6ebe21164468fe231749bea29d5152493ea61d42 (diff)
Tool System: set a default tool for each mode
Also clear tools for the default startup file so changes to defaults apply to new files.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_workspace.h3
-rw-r--r--source/blender/blenkernel/intern/workspace.c25
2 files changed, 18 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 4f4ae9f375b..6902fb631e4 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -28,6 +28,7 @@
#include "BLI_compiler_attrs.h"
struct bScreen;
+struct bToolRef;
struct Main;
struct Scene;
struct TransformOrientation;
@@ -70,6 +71,8 @@ struct WorkSpaceLayout *BKE_workspace_layout_iter_circular(
bool (*callback)(const struct WorkSpaceLayout *layout, void *arg),
void *arg, const bool iter_backward);
+void BKE_workspace_tool_remove(
+ struct WorkSpace *workspace, struct bToolRef *tref) ATTR_NONNULL(1, 2);
/* -------------------------------------------------------------------- */
/* Getters/Setters */
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 2829708391f..0b1f9d8bd24 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -161,17 +161,9 @@ void BKE_workspace_free(WorkSpace *workspace)
BLI_freelistN(&workspace->owner_ids);
BLI_freelistN(&workspace->layouts);
- for (bToolRef *tref = workspace->tools.first, *tref_next; tref; tref = tref_next) {
- tref_next = tref->next;
- if (tref->runtime) {
- MEM_freeN(tref->runtime);
- }
- if (tref->properties) {
- IDP_FreeProperty(tref->properties);
- MEM_freeN(tref->properties);
- }
+ while (!BLI_listbase_is_empty(&workspace->tools)) {
+ BKE_workspace_tool_remove(workspace, workspace->tools.first);
}
- BLI_freelistN(&workspace->tools);
if (workspace->status_text) {
MEM_freeN(workspace->status_text);
@@ -352,6 +344,19 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(
return NULL;
}
+void BKE_workspace_tool_remove(
+ struct WorkSpace *workspace, struct bToolRef *tref)
+{
+ if (tref->runtime) {
+ MEM_freeN(tref->runtime);
+ }
+ if (tref->properties) {
+ IDP_FreeProperty(tref->properties);
+ MEM_freeN(tref->properties);
+ }
+ BLI_remlink(&workspace->tools, tref);
+ MEM_freeN(tref);
+}
/* -------------------------------------------------------------------- */
/* Getters/Setters */