[glade] Report parsing error when loading a project. Fixes Bug 712289 "Glade silently fails to open malforme
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Report parsing error when loading a project. Fixes Bug 712289 "Glade silently fails to open malforme
- Date: Sat, 16 Nov 2013 02:53:01 +0000 (UTC)
commit af72b2dad1f4fa153a7449312841eec4d0a1e1dc
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Fri Nov 15 20:59:11 2013 -0300
Report parsing error when loading a project.
Fixes Bug 712289 "Glade silently fails to open malformed ui file"
gladeui/Makefile.am | 1 +
gladeui/glade-private.h | 41 +++++++++++++++++++++++++++++++++++++++++
gladeui/glade-project.c | 16 +++++++++++++++-
gladeui/glade-xml-utils.c | 21 +++++++++++++++++++++
4 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index c1e391a..7e78bcb 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -194,6 +194,7 @@ noinst_HEADERS = \
glade-preview-tokens.h \
glade-preview-window.h \
glade-preview-template.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 0000000..ea35011
--- /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 0553a2e..e1acd14 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,
@@ -2285,11 +2286,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 e9c9145..9b9424c 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;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]