Fix T89284: Greasepencil top bar draw tool settings missing

Caused by {rBe3faef686d38}.

Error was getting the preview [which wasnt there yet]
These only appeared once the material tab in the Properties Editor was
used (since this ensured a valid preview icon).

Above commit changed behavior for RNA icon getter (this does not create
data anymore), so ensure the preview by hand here.

Maniphest Tasks: T89284

Differential Revision: https://developer.blender.org/D12178
This commit is contained in:
Philipp Oeser 2021-08-10 09:27:05 +02:00
parent 76d52cbcb4
commit 182edd4c35
Notes: blender-bot 2023-02-14 04:56:36 +01:00
Referenced by commit 3e81d177ea, Fix Grease Pencil materials added by Python missing
Referenced by issue #89284, Grease pencil: top bar draw tool settings don't appear until material properties tab is clicked
1 changed files with 9 additions and 8 deletions

View File

@ -1141,14 +1141,15 @@ def brush_basic__draw_color_selector(context, layout, brush, gp_settings, props)
if not gp_settings.use_material_pin:
ma = context.object.active_material
icon_id = 0
if ma and ma.id_data.preview:
icon_id = ma.id_data.preview.icon_id
txt_ma = ma.name
maxw = 25
if len(txt_ma) > maxw:
txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
else:
txt_ma = ""
txt_ma = ""
if ma:
ma.id_data.preview_ensure()
if ma.id_data.preview:
icon_id = ma.id_data.preview.icon_id
txt_ma = ma.name
maxw = 25
if len(txt_ma) > maxw:
txt_ma = txt_ma[:maxw - 5] + '..' + txt_ma[-3:]
sub = row.row()
sub.ui_units_x = 8