fix [#25520] crash when closing the properties panel in uv/image editor
don't draw the image if the size is 0. Crash was actually an assert() so debug builds only, replace assert() with BKE_assert() so crash is opt in build option.
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
@@ -851,7 +850,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
|
||||
/* sanity check */
|
||||
if(w<=0 || h<=0 || w>2000 || h>2000) {
|
||||
printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h);
|
||||
assert(!"invalid icon size");
|
||||
BKE_assert(!"invalid icon size");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -747,7 +747,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
|
||||
static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha), rcti *rect)
|
||||
{
|
||||
int w, h, x, y, size;
|
||||
int w, h, size;
|
||||
|
||||
if(icon==ICON_NULL)
|
||||
return;
|
||||
@@ -756,11 +756,13 @@ static void widget_draw_preview(BIFIconID icon, float aspect, float UNUSED(alpha
|
||||
h = rect->ymax - rect->ymin;
|
||||
size = MIN2(w, h);
|
||||
size -= PREVIEW_PAD*2; /* padding */
|
||||
|
||||
x = rect->xmin + w/2 - size/2;
|
||||
y = rect->ymin + h/2 - size/2;
|
||||
|
||||
UI_icon_draw_preview_aspect_size(x, y, icon, aspect, size);
|
||||
|
||||
if(size > 0) {
|
||||
int x = rect->xmin + w/2 - size/2;
|
||||
int y = rect->ymin + h/2 - size/2;
|
||||
|
||||
UI_icon_draw_preview_aspect_size(x, y, icon, aspect, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user