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.
So a valid `Paint` and `Brush` were assumed. This is not a problem for
objectmode (because `BKE_paint_get_active_from_context` then defaults to
`ImagePaintSettings`'s `Paint`), but other modes dont guarantee this
(editmode only returns a valid `Paint` when uv sculpting).
In the report, a palette was created and displayed via python, making
changes in editmode would then crash.
Solve by checking we have a valid Paint in corresponding UI code to
begin with.
Similar to 9e82e48937 .