mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Don't crash on a missing fonts. Exit cleanly.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7213 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
37c6ba9e35
commit
86dd93bfe8
@ -386,7 +386,8 @@ gnc_gui_init (SCM command_line)
|
||||
NULL, "Register",
|
||||
"Register hint font");
|
||||
|
||||
gnucash_style_init();
|
||||
if (!gnucash_style_init())
|
||||
gnc_shutdown(1);
|
||||
gnucash_color_init();
|
||||
|
||||
gnc_html_register_url_handler (URL_TYPE_REGISTER,
|
||||
|
@ -106,7 +106,7 @@ gnc_main_window_get_mdi_child (void)
|
||||
* gnc_shutdown
|
||||
* close down gnucash from the C side...
|
||||
********************************************************************/
|
||||
static void
|
||||
void
|
||||
gnc_shutdown (int exit_status)
|
||||
{
|
||||
/*SCM scm_shutdown = gnc_scm_lookup("gnucash bootstrap", "gnc:shutdown");*/
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "gnc-mdi-utils.h"
|
||||
|
||||
GNCMDIInfo * gnc_main_window_new (void);
|
||||
void gnc_shutdown(int);
|
||||
|
||||
/*
|
||||
* Functions used as callbacks from multiple dialogs.
|
||||
|
@ -31,7 +31,11 @@
|
||||
#include "gnucash-item-edit.h"
|
||||
#include "gnucash-style.h"
|
||||
#include "messages.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
#define DEFAULT_STYLE_WIDTH 680
|
||||
|
||||
@ -811,64 +815,69 @@ gnucash_style_get_default_register_hint_font_name (void)
|
||||
void
|
||||
gnucash_style_set_register_font_name (const char *name)
|
||||
{
|
||||
g_free (register_font_name);
|
||||
register_font_name = g_strdup (name);
|
||||
GdkFont *new_font = NULL;
|
||||
|
||||
if (gnucash_register_font != NULL)
|
||||
{
|
||||
gdk_font_unref (gnucash_register_font);
|
||||
gnucash_register_font = NULL;
|
||||
}
|
||||
if (name != NULL) {
|
||||
new_font = gnucash_font_load (name);
|
||||
if (new_font == NULL) {
|
||||
PWARN("Cannot load font: %s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
if (register_font_name != NULL)
|
||||
gnucash_register_font = gnucash_font_load (register_font_name);
|
||||
if (new_font == NULL)
|
||||
{
|
||||
name = gnucash_style_get_default_register_font_name ();
|
||||
new_font = gnucash_font_load (name);
|
||||
if (new_font == NULL) {
|
||||
FATAL("Cannot load fallback font: %s\n", name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gnucash_register_font == NULL)
|
||||
{
|
||||
const char *name =
|
||||
gnucash_style_get_default_register_font_name ();
|
||||
if (gnucash_register_font != NULL)
|
||||
gdk_font_unref (gnucash_register_font);
|
||||
if (register_font_name != NULL)
|
||||
g_free (register_font_name);
|
||||
|
||||
g_free (register_font_name);
|
||||
register_font_name = NULL;
|
||||
gnucash_register_font = new_font;
|
||||
gdk_font_ref (gnucash_register_font);
|
||||
register_font_name = g_strdup (name);
|
||||
|
||||
gnucash_register_font = gnucash_font_load (name);
|
||||
}
|
||||
|
||||
g_assert (gnucash_register_font != NULL);
|
||||
|
||||
gdk_font_ref (gnucash_register_font);
|
||||
g_assert (gnucash_register_font != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_style_set_register_hint_font_name (const char *name)
|
||||
{
|
||||
g_free (register_hint_font_name);
|
||||
register_hint_font_name = g_strdup (name);
|
||||
GdkFont *new_font = NULL;
|
||||
|
||||
if (gnucash_register_hint_font != NULL)
|
||||
{
|
||||
gdk_font_unref (gnucash_register_hint_font);
|
||||
gnucash_register_hint_font = NULL;
|
||||
}
|
||||
if (name != NULL) {
|
||||
new_font = gnucash_font_load (name);
|
||||
if (new_font == NULL) {
|
||||
PWARN("Cannot load font: %s\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
if (register_hint_font_name != NULL)
|
||||
gnucash_register_hint_font =
|
||||
gnucash_font_load (register_hint_font_name);
|
||||
if (new_font == NULL)
|
||||
{
|
||||
name = gnucash_style_get_default_register_hint_font_name ();
|
||||
new_font = gnucash_font_load (name);
|
||||
if (new_font == NULL) {
|
||||
FATAL("Cannot load fallback font: %s\n", name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (gnucash_register_hint_font == NULL)
|
||||
{
|
||||
const char *name =
|
||||
gnucash_style_get_default_register_hint_font_name ();
|
||||
if (gnucash_register_hint_font != NULL)
|
||||
gdk_font_unref (gnucash_register_hint_font);
|
||||
if (register_hint_font_name != NULL)
|
||||
g_free (register_hint_font_name);
|
||||
|
||||
g_free (register_hint_font_name);
|
||||
register_hint_font_name = NULL;
|
||||
gnucash_register_hint_font = new_font;
|
||||
gdk_font_ref (gnucash_register_hint_font);
|
||||
register_hint_font_name = g_strdup (name);
|
||||
|
||||
gnucash_register_hint_font = gnucash_font_load (name);
|
||||
}
|
||||
|
||||
g_assert (gnucash_register_hint_font != NULL);
|
||||
|
||||
gdk_font_ref (gnucash_register_hint_font);
|
||||
g_assert (gnucash_register_hint_font != NULL);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@ -1013,7 +1022,7 @@ gnucash_sheet_set_header_widths (GnucashSheet *sheet,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gnucash_style_init (void)
|
||||
{
|
||||
if (gnucash_register_font == NULL)
|
||||
@ -1021,6 +1030,9 @@ gnucash_style_init (void)
|
||||
|
||||
if (gnucash_register_hint_font == NULL)
|
||||
gnucash_style_set_register_hint_font_name(NULL);
|
||||
|
||||
return ((gnucash_register_font != NULL) &&
|
||||
(gnucash_register_hint_font != NULL));
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ struct _SheetBlockStyle
|
||||
};
|
||||
|
||||
|
||||
void gnucash_style_init (void);
|
||||
gboolean gnucash_style_init (void);
|
||||
|
||||
void gnucash_sheet_style_init(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user