[Bf-blender-cvs] [ba339379fe5] blender2.8: Fix linking brushes crashing on load
Campbell Barton
noreply at git.blender.org
Mon Apr 30 20:09:48 CEST 2018
Commit: ba339379fe575b59bb16ccaf37144be417e4f424
Author: Campbell Barton
Date: Mon Apr 30 20:07:32 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBba339379fe575b59bb16ccaf37144be417e4f424
Fix linking brushes crashing on load
We need to link brushes for all windows that use a workspace.
===================================================================
M source/blender/windowmanager/intern/wm_toolsystem.c
===================================================================
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);
+ }
+ }
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list