From dc92dbfc56e2801233d6c7a21bc07f8763d9cc67 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 21 Jun 2003 05:35:05 +0000 Subject: [PATCH] don't exit in the render lib, rather return a NULL font/theme on failure --- render/font.c | 5 ++--- render/theme.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/render/font.c b/render/font.c index 592ced6f..b9a17b48 100644 --- a/render/font.c +++ b/render/font.c @@ -23,7 +23,7 @@ static void font_startup(void) #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 @@ RrFont *RrFontOpen(const RrInstance *inst, char *fontstring) 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) diff --git a/render/theme.c b/render/theme.c index 1a38093a..7e45b86f 100644 --- a/render/theme.c +++ b/render/theme.c @@ -27,7 +27,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) gchar *font_str; RrTheme *theme; - theme = g_new(RrTheme, 1); + theme = g_new0(RrTheme, 1); theme->inst = inst; @@ -125,7 +125,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) 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 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) 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 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) 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); -- 2.45.2