Fix: UI: Crash when trying to display invalid icon
Requesting an icon from an invalid icon ID was always handled
gracefully, resulting in the icon not being shown and an error print in
debug mode. 2b7a968909 caused a null pointer dereference in that case,
leading to a crash.
This commit is contained in:
@@ -1469,11 +1469,6 @@ static void icon_draw_size(float x,
|
||||
|
||||
Icon *icon = BKE_icon_get(icon_id);
|
||||
|
||||
if (icon->obj_type != ICON_DATA_STUDIOLIGHT) {
|
||||
/* Icon alpha should not apply to MatCap/Studio lighting. #80356. */
|
||||
alpha *= btheme->tui.icon_alpha;
|
||||
}
|
||||
|
||||
if (icon == nullptr) {
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
@@ -1481,6 +1476,11 @@ static void icon_draw_size(float x,
|
||||
return;
|
||||
}
|
||||
|
||||
if (icon->obj_type != ICON_DATA_STUDIOLIGHT) {
|
||||
/* Icon alpha should not apply to MatCap/Studio lighting. #80356. */
|
||||
alpha *= btheme->tui.icon_alpha;
|
||||
}
|
||||
|
||||
/* scale width and height according to aspect */
|
||||
int w = int(fdraw_size / aspect + 0.5f);
|
||||
int h = int(fdraw_size / aspect + 0.5f);
|
||||
|
||||
Reference in New Issue
Block a user