don't exit in the render lib, rather return a NULL font/theme on failure
Dana Jansens danakj@orodu.net
2 files changed,
15 insertions(+),
7 deletions(-)
M
render/font.c
→
render/font.c
@@ -23,7 +23,7 @@ int version;
#endif /* DEBUG */ if (!XftInit(0)) { g_warning(_("Couldn't initialize Xft.\n")); - exit(3); + exit(EXIT_FAILURE); } #ifdef DEBUG version = XftGetVersion();@@ -71,9 +71,8 @@ measure_font(out);
return out; } g_warning(_("Unable to load font: %s\n"), "sans"); - g_warning(_("Aborting!.\n")); - exit(3); /* can't continue without a font */ + return NULL; } void RrFontClose(RrFont *f)
M
render/theme.c
→
render/theme.c
@@ -27,7 +27,7 @@ gchar *str;
gchar *font_str; RrTheme *theme; - theme = g_new(RrTheme, 1); + theme = g_new0(RrTheme, 1); theme->inst = inst;@@ -125,7 +125,10 @@ &theme->winfont_shadow_tint) ||
theme->winfont_shadow_tint < 100 || theme->winfont_shadow_tint > 100) theme->winfont_shadow_tint = 25; - theme->winfont = RrFontOpen(inst, font_str); + if (!(theme->winfont = RrFontOpen(inst, font_str))) { + RrThemeFree(theme); + return NULL; + } theme->winfont_height = RrFontHeight(theme->winfont, theme->winfont_shadow, theme->winfont_shadow_offset);@@ -156,7 +159,10 @@ theme->mtitlefont_shadow_tint < 100 ||
theme->mtitlefont_shadow_tint > 100) theme->mtitlefont_shadow_tint = 25; - theme->mtitlefont = RrFontOpen(inst, font_str); + if (!(theme->mtitlefont = RrFontOpen(inst, font_str))) { + RrThemeFree(theme); + return NULL; + } theme->mtitlefont_height = RrFontHeight(theme->mtitlefont, theme->mtitlefont_shadow, theme->mtitlefont_shadow_offset);@@ -188,7 +194,10 @@ theme->mfont_shadow_tint < 100 ||
theme->mfont_shadow_tint > 100) theme->mfont_shadow_tint = 25; - theme->mfont = RrFontOpen(inst, font_str); + if (!(theme->mfont = RrFontOpen(inst, font_str))) { + RrThemeFree(theme); + return NULL; + } theme->mfont_height = RrFontHeight(theme->mfont, theme->mfont_shadow, theme->mfont_shadow_offset);