summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2013-11-15 20:59:11 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2013-11-15 23:39:55 -0300
commitdb7bee0c4b6e58ad672d0a1b08e26bcdc9658f85 (patch)
tree5b88d943ffa85a802d023b0d83c9bbc1a93e254d
parent592516f7499a5dfa7483b2200e6896dfe4fdcc3a (diff)
downloadglade-db7bee0c4b6e58ad672d0a1b08e26bcdc9658f85.tar.gz
Report parsing error when loading a project.
Fixes Bug 712289 "Glade silently fails to open malformed ui file"
-rw-r--r--gladeui/Makefile.am1
-rw-r--r--gladeui/glade-private.h41
-rw-r--r--gladeui/glade-project.c16
-rw-r--r--gladeui/glade-xml-utils.c21
4 files changed, 78 insertions, 1 deletions
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index 230efda9..077da12c 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -190,6 +190,7 @@ noinst_HEADERS = \
glade-popup.h \
glade-preview.h \
glade-preview-tokens.h \
+ glade-private.h \
glade-project-properties.h \
gladeui-resources.h \
glade-drag.h \
diff --git a/gladeui/glade-private.h b/gladeui/glade-private.h
new file mode 100644
index 00000000..ea35011d
--- /dev/null
+++ b/gladeui/glade-private.h
@@ -0,0 +1,41 @@
+/*
+ * glade-private.h: miscellaneous private API
+ *
+ * This is a placeholder for private API, eventually it should be replaced by
+ * proper public API or moved to its own private file.
+ *
+ * Copyright (C) 2013 Juan Pablo Ugarte
+ *
+ * Authors:
+ * Juan Pablo Ugarte <juanpablougarte@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __GLADE_PRIVATE_H__
+#define __GLADE_PRIVATE_H__
+
+G_BEGIN_DECLS
+
+/* glade-xml-utils.c */
+
+/* GladeXml Error handling */
+void _glade_xml_error_reset_last (void);
+gchar *_glade_xml_error_get_last_message (void);
+
+G_END_DECLS
+
+#endif /* __GLADE_PRIVATE_H__ */
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 2f768627..85d47f36 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -54,6 +54,7 @@
#include "glade-object-stub.h"
#include "glade-project-properties.h"
#include "glade-dnd.h"
+#include "glade-private.h"
static void glade_project_target_version_for_adaptor
(GladeProject *project,
@@ -2148,11 +2149,24 @@ glade_project_load_internal (GladeProject *project)
priv->objects = NULL;
priv->loading = TRUE;
+ _glade_xml_error_reset_last ();
+
/* get the context & root node of the catalog file */
if (!(context =
glade_xml_context_new_from_path (load_path ? load_path : priv->path, NULL, NULL)))
{
- g_warning ("Couldn't open glade file [%s].", load_path ? load_path : priv->path);
+ gchar *message = _glade_xml_error_get_last_message ();
+
+ if (message)
+ {
+ glade_util_ui_message (glade_app_get_window (), GLADE_UI_ERROR, NULL, message);
+ g_free (message);
+ }
+ else
+ glade_util_ui_message (glade_app_get_window (), GLADE_UI_ERROR, NULL,
+ "Couldn't open glade file [%s].",
+ load_path ? load_path : priv->path);
+
g_free (load_path);
priv->loading = FALSE;
return FALSE;
diff --git a/gladeui/glade-xml-utils.c b/gladeui/glade-xml-utils.c
index e9c91456..9b9424cc 100644
--- a/gladeui/glade-xml-utils.c
+++ b/gladeui/glade-xml-utils.c
@@ -987,3 +987,24 @@ glade_xml_node_add_next_sibling (GladeXmlNode *node, GladeXmlNode *new_node)
{
return (GladeXmlNode *) xmlAddNextSibling ((xmlNodePtr) node, (xmlNodePtr) new_node);
}
+
+
+/* Private API */
+#include "glade-private.h"
+
+void
+_glade_xml_error_reset_last (void)
+{
+ xmlResetLastError ();
+}
+
+gchar *
+_glade_xml_error_get_last_message ()
+{
+ xmlErrorPtr error = xmlGetLastError ();
+
+ if (error)
+ return g_strdup_printf ("Error parsing file '%s' on line %d \n%s",
+ error->file, error->line, error->message);
+ return NULL;
+}