Prevent some more crashes

This commit is contained in:
twinaphex 2016-02-29 02:09:10 +01:00
parent 4f1ab1f9c3
commit b4e872476b
3 changed files with 13 additions and 6 deletions

View File

@ -200,7 +200,7 @@ static int gl_get_message_width(void *data, const char *msg,
unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
int delta_x = 0;
if (!font)
if (!font || !font->font_driver)
return 0;
while (msg_len_full)
@ -209,6 +209,7 @@ static int gl_get_message_width(void *data, const char *msg,
{
const struct font_glyph *glyph =
font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
if (!glyph) /* Do something smarter here ... */
glyph = font->font_driver->get_glyph(font->font_data, '?');
if (!glyph)
@ -340,7 +341,11 @@ static void gl_raster_font_render_message(
int lines = 0;
float line_height;
if (!msg || !*msg || !font->gl)
if ( !msg
|| !*msg
|| !font->gl
|| !font
|| !font->font_driver)
return;
/* If the font height is not supported just draw as usual */

View File

@ -233,11 +233,10 @@ static const char *font_renderer_ft_get_default_font(void)
static int font_renderer_ft_get_line_height(void* data)
{
ft_font_renderer_t *handle = (ft_font_renderer_t*)data;
if (!handle)
ft_font_renderer_t *handle = (ft_font_renderer_t*)data;
if (!handle || !handle->face)
return 0;
return handle->face->size->metrics.height/64;
return handle->face->size->metrics.height/64;
}
font_renderer_driver_t freetype_font_renderer = {

View File

@ -861,6 +861,9 @@ static int zarch_zui_render_lay_root(zui_t *zui)
tabbed.width = zui->width - 290 - 40;
zui->next_selection_set = false;
if (!zui)
return 1;
if (zarch_zui_render_lay_root_recent(zui, &tabbed))
return 0;
if (zarch_zui_render_lay_root_load (zui, &tabbed))