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>2015-11-02 13:37:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-11-02 13:42:47 +0300
commit7b7aba31f24d51c904c76a17ee50608b770e1bc9 (patch)
tree326c218109d49fe285579ace7e4097643a9a8cdc /source/blender/blenkernel/intern/brush.c
parent7a9693fa8ba2132e09a892dfa0e60736b741002a (diff)
Fix T46626: Crash generating previews
Brush.toggle_brush was allowed to be an invalid pointer, it worked for the one operator that used it - but in general bad practice, requiring a lookup on every access. Ensure the pointer is kept valid now.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index c2a66adbf92..95b65f52bd0 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -223,11 +223,27 @@ void BKE_brush_free(Brush *brush)
MEM_freeN(brush->gradient);
}
+/**
+ * \note Currently users don't remove brushes from the UI (as is done for scene, text... etc)
+ * This is only used by RNA, which can remove brushes.
+ */
+void BKE_brush_unlink(Main *bmain, Brush *brush)
+{
+ Brush *brush_iter;
+
+ for (brush_iter = bmain->brush.first; brush_iter; brush_iter = brush_iter->id.next) {
+ if (brush_iter->toggle_brush == brush) {
+ brush_iter->toggle_brush = NULL;
+ }
+ }
+}
+
static void extern_local_brush(Brush *brush)
{
id_lib_extern((ID *)brush->mtex.tex);
id_lib_extern((ID *)brush->mask_mtex.tex);
id_lib_extern((ID *)brush->clone.image);
+ id_lib_extern((ID *)brush->toggle_brush);
id_lib_extern((ID *)brush->paint_curve);
}