From 5aa95941d1decbb393dd5b5939d81ef92c1ddb53 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 27 Nov 2024 15:41:26 +0100 Subject: [PATCH] Fix #130998: Crash changing Color Palette in Object/Edit/Pose modes Caused by 7b0ea0f1b430 By default, Color Palettes are only drawn in the UI in the context of **painting**. UI button code then tries to update an appropriate brush from edits to the palette. In the report though, a palette was created and displayed via python, making changes in Object/Edit/Pose would then crash. So a valid `Paint` and `Brush` were assumed. `Paint` was already checked for in a324a19f1bc7, but since 7b0ea0f1b430, `Paint`(if we actually have it, e.g.from `ImagePaintSettings` [see a324a19f1bc7]) only has its `brush` set once we enter texturepaint once. Solved by checking we have a valid Brush in corresponding UI code to begin with. Pull Request: https://projects.blender.org/blender/blender/pulls/131031 --- source/blender/editors/interface/interface_handlers.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index bd1e485d917..45012a3e789 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -6503,7 +6503,10 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if (paint != nullptr) { Brush *brush = BKE_paint_brush(paint); - if (brush->flag & BRUSH_USE_GRADIENT) { + if (brush == nullptr) { + /* Pass. */ + } + else if (brush->flag & BRUSH_USE_GRADIENT) { float *target = &brush->gradient->data[brush->gradient->cur].r; if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {