r20537 - gnucash/trunk/src/gnome-utils - Add useful error message when running gnucash from an incomplete installation (such as from the build directory).
Christian Stimming
cstim at code.gnucash.org
Wed Apr 6 06:20:32 EDT 2011
Author: cstim
Date: 2011-04-06 06:20:32 -0400 (Wed, 06 Apr 2011)
New Revision: 20537
Trac: http://svn.gnucash.org/trac/changeset/20537
Modified:
gnucash/trunk/src/gnome-utils/dialog-utils.c
gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
Log:
Add useful error message when running gnucash from an incomplete installation (such as from the build directory).
Modified: gnucash/trunk/src/gnome-utils/dialog-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.c 2011-04-05 20:18:45 UTC (rev 20536)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.c 2011-04-06 10:20:32 UTC (rev 20537)
@@ -820,9 +820,22 @@
}
gnc_glade_dir = gnc_path_get_gladedir ();
+ if (!g_file_test(gnc_glade_dir, G_FILE_TEST_IS_DIR))
+ {
+ g_critical("Directory for glade UI files \"%s\" is not found. Your installation is incomplete and cannot be run.", gnc_glade_dir);
+ g_free (gnc_glade_dir);
+ return NULL;
+ }
+
fname = g_build_filename(gnc_glade_dir, filename, (char *)NULL);
g_free (gnc_glade_dir);
+ if (!g_file_test(fname, G_FILE_TEST_EXISTS))
+ {
+ g_critical("The glade UI file \"%s\" is not found. Your installation is incomplete and cannot be run.", fname);
+ return NULL;
+ }
+
xml = glade_xml_new (fname, root, NULL);
g_free (fname);
Modified: gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2011-04-05 20:18:45 UTC (rev 20536)
+++ gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2011-04-06 10:20:32 UTC (rev 20537)
@@ -676,7 +676,14 @@
#endif /* G_OS_WIN32 */
xml = gnc_glade_xml_new ("druid-gconf-setup.glade", "GConf Query");
+ if (!xml)
+ {
+ gnc_error_dialog(NULL, "The glade UI files were not found. Your installation is incomplete and cannot be run.");
+ exit(-1); /* quit immediately */
+ }
+ g_assert(xml);
dialog = glade_xml_get_widget (xml, "GConf Query");
+ g_assert(dialog);
do
{
response = gtk_dialog_run(GTK_DIALOG(dialog));
Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2011-04-05 20:18:45 UTC (rev 20536)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c 2011-04-06 10:20:32 UTC (rev 20537)
@@ -260,7 +260,26 @@
gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir ();
gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
gchar *pkglibdir = gnc_path_get_pkglibdir ();
+ gboolean installation_ok = TRUE;
+ /* Verify all the various directory before proceeding */
+ if (!g_file_test(pkgdatadir, G_FILE_TEST_IS_DIR))
+ {
+ g_critical("The installation data directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgdatadir);
+ installation_ok = FALSE;
+ }
+ if (!g_file_test(pkglibdir, G_FILE_TEST_IS_DIR))
+ {
+ g_critical("The installation lib directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkglibdir);
+ installation_ok = FALSE;
+ }
+
+ if (!g_file_test(pkgsysconfdir, G_FILE_TEST_IS_DIR))
+ {
+ g_critical("The installation sysconf directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgsysconfdir);
+ installation_ok = FALSE;
+ }
+
gnc_gtk_add_rc_file();
gnucash_program = gnome_program_init(
"gnucash", version, LIBGNOMEUI_MODULE,
@@ -270,11 +289,29 @@
GNOME_PARAM_APP_DATADIR, pkgdatadir,
GNOME_PARAM_APP_LIBDIR, pkglibdir,
GNOME_PARAM_NONE);
+ if (!installation_ok)
+ {
+ /* The following string does not need translation because if
+ * it shows up, the program is unusable anyway. */
+ gnc_error_dialog(NULL, "The installation directories were not found.\n\ndatadir=%s\nlibdir=%s\nsysconfdir=%s\n\nYour installation is incomplete and cannot be run.",
+ pkgdatadir, pkglibdir, pkgsysconfdir);
+ /* gnc_error_dialog must not be called before gnome_program_init. */
+ }
+
g_free (prefix);
g_free (pkgsysconfdir);
g_free (pkgdatadir);
g_free (pkglibdir);
+ /* Did the installation directory check fail? Terminate
+ * immediately because it will inevitably fail in the glade file
+ * lookup. */
+ if (!installation_ok)
+ {
+ /* No correct installation? Shut down immediately. */
+ exit(-1);
+ }
+
#ifdef G_OS_WIN32
/* workaround for bug #421792 */
xmlCleanupInputCallbacks();
More information about the gnucash-changes
mailing list