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-05-18 18:32:38 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-18 18:36:11 +0300
commitf9547ab3133654f7dac805f9d61c49183fa2046c (patch)
tree8e57fe4457f2e070d2fe219bbf41d6532b56ded8 /source/blender
parentc2d5411cbfe2da4b4a274a8695cec8a024cad886 (diff)
Fix tools not being initialized on startup
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/screen/workspace_edit.c2
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h5
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c76
4 files changed, 59 insertions, 28 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index fe52e945399..35d916e403d 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -202,7 +202,7 @@ bool ED_workspace_change(
BLI_assert(CTX_wm_workspace(C) == workspace_new);
WM_toolsystem_unlink_all(C, workspace_old);
- WM_toolsystem_link_all(C, workspace_new);
+ WM_toolsystem_reinit_all(C, win);
return true;
}
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 12dd2d9962a..24fa0e06d90 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -71,8 +71,11 @@ typedef struct bToolRef {
struct bToolRef *next, *prev;
char idname[64];
+ /** Use to avoid initializing the same tool multiple times. */
+ short tag;
+
/** bToolKey (spacetype, mode), used in 'WM_api.h' */
- int space_type;
+ short space_type;
/**
* Value depends ont the 'space_type', object mode for 3D view, image editor has own mode too.
* RNA needs to handle using item function.
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 0d48cd9ef20..e6b045bc249 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -611,14 +611,12 @@ struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C);
struct bToolRef_Runtime *WM_toolsystem_runtime_find(struct WorkSpace *workspace, const bToolKey *tkey);
void WM_toolsystem_unlink(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
-void WM_toolsystem_link(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
void WM_toolsystem_refresh(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
void WM_toolsystem_reinit(struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey);
void WM_toolsystem_unlink_all(struct bContext *C, struct WorkSpace *workspace);
-void WM_toolsystem_link_all(struct bContext *C, struct WorkSpace *workspace);
void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace);
-void WM_toolsystem_reinit_all(struct bContext *C, struct WorkSpace *workspace);
+void WM_toolsystem_reinit_all(struct bContext *C, struct wmWindow *win);
void WM_toolsystem_ref_set_from_runtime(
struct bContext *C, struct WorkSpace *workspace, struct bToolRef *tref,
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 122e292985a..3ef5882bc03 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -201,13 +201,6 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
-void WM_toolsystem_link(bContext *C, WorkSpace *workspace, const bToolKey *tkey)
-{
- bToolRef *tref = WM_toolsystem_ref_find(workspace, tkey);
- if (tref) {
- toolsystem_ref_link(C, workspace, tref);
- }
-}
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
{
@@ -241,30 +234,42 @@ void WM_toolsystem_reinit(bContext *C, WorkSpace *workspace, const bToolKey *tke
void WM_toolsystem_unlink_all(struct bContext *C, struct WorkSpace *workspace)
{
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
- if (tref->runtime) {
- toolsystem_unlink_ref(C, workspace, tref);
- }
+ tref->tag = 0;
}
-}
-void WM_toolsystem_link_all(struct bContext *C, struct WorkSpace *workspace)
-{
+
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
if (tref->runtime) {
- toolsystem_ref_link(C, workspace, tref);
+ if (tref->tag == 0) {
+ toolsystem_unlink_ref(C, workspace, tref);
+ tref->tag = 1;
+ }
}
}
}
+
void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace)
{
+ BLI_assert(0);
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
toolsystem_refresh_ref(C, workspace, tref);
}
}
-void WM_toolsystem_reinit_all(struct bContext *C, struct WorkSpace *workspace)
+void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win)
{
- LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
- if (tref->runtime) {
- toolsystem_reinit_ref(C, workspace, tref);
+ bScreen *screen = WM_window_get_active_screen(win);
+ Scene *scene = WM_window_get_active_scene(win);
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ const bToolKey tkey = {
+ .space_type = sa->spacetype,
+ .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ };
+ bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
+ if (tref) {
+ if (tref->tag == 0) {
+ toolsystem_reinit_ref(C, workspace, tref);
+ tref->tag = 1;
+ }
}
}
}
@@ -304,11 +309,37 @@ void WM_toolsystem_ref_set_from_runtime(
void WM_toolsystem_init(bContext *C)
{
Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- WorkSpace *workspace = WM_window_get_active_workspace(win);
- WM_toolsystem_refresh_all(C, workspace);
+ BLI_assert(CTX_wm_window(C) == NULL);
+
+ LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
+ MEM_SAFE_FREE(tref->runtime);
+ tref->tag = 0;
+ }
+ }
+
+ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ CTX_wm_window_set(C, win);
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ bScreen *screen = WM_window_get_active_screen(win);
+ Scene *scene = WM_window_get_active_scene(win);
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ const bToolKey tkey = {
+ .space_type = sa->spacetype,
+ .mode = WM_toolsystem_mode_from_spacetype(workspace, scene, sa, sa->spacetype),
+ };
+ bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
+ if (tref) {
+ if (tref->tag == 0) {
+ toolsystem_reinit_ref(C, workspace, tref);
+ tref->tag = 1;
+ }
+ }
+ }
+ CTX_wm_window_set(C, NULL);
+ }
}
}
@@ -426,7 +457,6 @@ static void toolsystem_refresh_screen_from_active_tool(
static void toolsystem_reinit_with_toolref(
bContext *C, WorkSpace *workspace, bToolRef *tref)
{
-
wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_name", false);
/* On startup, Python operatores are not yet loaded. */
if (ot == NULL) {