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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-30 21:07:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-30 21:09:39 +0300
commitba339379fe575b59bb16ccaf37144be417e4f424 (patch)
treea7bee3b10bc99420f5bb81654bf1d8e341191c11 /source
parent33bb8b785a938da64d55687d50f1a78cd6bbb733 (diff)
Fix linking brushes crashing on load
We need to link brushes for all windows that use a workspace.
Diffstat (limited to 'source')
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index bf9583e3713..66e84406ebb 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -38,6 +38,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_paint.h"
+#include "BKE_workspace.h"
#include "RNA_access.h"
@@ -79,13 +80,26 @@ void WM_toolsystem_link(bContext *C, WorkSpace *workspace)
if (workspace->tool.manipulator_group[0]) {
WM_manipulator_group_type_ensure(workspace->tool.manipulator_group);
}
+
if (workspace->tool.data_block[0]) {
+ Main *bmain = CTX_data_main(C);
+
/* Currently only brush data-blocks supported. */
- Paint *paint = BKE_paint_get_active_from_context(C);
- if (paint) {
- struct Brush *brush = (struct Brush *)BKE_libblock_find_name(ID_BR, workspace->tool.data_block);
- if (brush) {
- BKE_paint_brush_set(paint, brush);
+ struct Brush *brush = (struct Brush *)BKE_libblock_find_name(ID_BR, workspace->tool.data_block);
+
+ if (brush) {
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ if (workspace == WM_window_get_active_workspace(win)) {
+ Scene *scene = win->scene;
+ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
+ Paint *paint = BKE_paint_get_active(scene, view_layer);
+ if (paint) {
+ if (brush) {
+ BKE_paint_brush_set(paint, brush);
+ }
+ }
+ }
}
}
}