dia r4233 - in trunk: . app
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4233 - in trunk: . app
- Date: Fri, 30 Jan 2009 17:16:00 +0000 (UTC)
Author: hans
Date: Fri Jan 30 17:16:00 2009
New Revision: 4233
URL: http://svn.gnome.org/viewvc/dia?rev=4233&view=rev
Log:
2009-01-30 Hans Breuer <hans breuer org>
* app/load_save.c : do not complain about missing object types per
layer but just once per diagram
* app/confirm.c : there is no glib-3.16 yet
Modified:
trunk/ChangeLog
trunk/app/confirm.c
trunk/app/load_save.c
Modified: trunk/app/confirm.c
==============================================================================
--- trunk/app/confirm.c (original)
+++ trunk/app/confirm.c Fri Jan 30 17:16:00 2009
@@ -60,7 +60,7 @@
return TRUE;
/* message and limits depend on the flags give */
-#if GLIB_CHECK_VERSION(3,16,0)
+#if GLIB_CHECK_VERSION(2,16,0)
size = g_format_size_for_display (bytes);
#else
size = g_strdup_printf ("%d MB", (guint)(bytes >> 20));
Modified: trunk/app/load_save.c
==============================================================================
--- trunk/app/load_save.c (original)
+++ trunk/app/load_save.c Fri Jan 30 17:16:00 2009
@@ -65,7 +65,8 @@
gpointer user_data);
static GList *read_objects(xmlNodePtr objects,
GHashTable *objects_hash,
- const char *filename, DiaObject *parent);
+ const char *filename, DiaObject *parent,
+ GHashTable *unknown_objects_hash);
static void hash_free_string(gpointer key,
gpointer value,
gpointer user_data);
@@ -112,7 +113,8 @@
*/
static GList *
read_objects(xmlNodePtr objects,
- GHashTable *objects_hash,const char *filename, DiaObject *parent)
+ GHashTable *objects_hash,const char *filename, DiaObject *parent,
+ GHashTable *unknown_objects_hash)
{
GList *list;
DiaObjectType *type;
@@ -122,13 +124,8 @@
char *versionstr;
char *id;
int version;
- GHashTable* unknown_hash;
- GString* unknown_str;
xmlNodePtr child_node;
- unknown_hash = g_hash_table_new(g_str_hash, g_str_equal);
- unknown_str = g_string_new("Unknown types while reading diagram file");
-
list = NULL;
obj_node = objects->xmlChildrenNode;
@@ -155,8 +152,9 @@
type = object_get_type((char *)typestr);
if (!type) {
- if (NULL == g_hash_table_lookup(unknown_hash, typestr))
- g_hash_table_insert(unknown_hash, g_strdup(typestr), 0);
+ if (g_utf8_validate (typestr, -1, NULL) &&
+ NULL == g_hash_table_lookup(unknown_objects_hash, typestr))
+ g_hash_table_insert(unknown_objects_hash, g_strdup(typestr), 0);
}
else
{
@@ -177,7 +175,7 @@
{
if (xmlStrcmp(child_node->name, (const xmlChar *)"children") == 0)
{
- GList *children_read = read_objects(child_node, objects_hash, filename, obj);
+ GList *children_read = read_objects(child_node, objects_hash, filename, obj, unknown_objects_hash);
list = g_list_concat(list, children_read);
break;
}
@@ -189,7 +187,7 @@
} else if (xmlStrcmp(obj_node->name, (const xmlChar *)"group")==0
&& obj_node->children) {
/* don't create empty groups */
- obj = group_create(read_objects(obj_node, objects_hash, filename, NULL));
+ obj = group_create(read_objects(obj_node, objects_hash, filename, NULL, unknown_objects_hash));
#ifdef USE_NEWGROUP
/* Old group objects had objects recursively inside them. Since
* objects are now done with parenting, we need to extract those objects,
@@ -235,16 +233,6 @@
obj_node = obj_node->next;
}
- /* show all the unknown types in one message */
- if (0 < g_hash_table_size(unknown_hash)) {
- g_hash_table_foreach(unknown_hash,
- GHFuncUnknownObjects,
- unknown_str);
- message_error("%s", unknown_str->str);
- }
- g_hash_table_destroy(unknown_hash);
- g_string_free(unknown_str, TRUE);
-
return list;
}
@@ -421,6 +409,8 @@
gchar firstchar;
Diagram *diagram = DIA_IS_DIAGRAM (data) ? DIA_DIAGRAM (data) : NULL;
Layer *active_layer = NULL;
+ GHashTable* unknown_objects_hash = g_hash_table_new(g_str_hash, g_str_equal);
+
if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
message_error(_("You must specify a file, not a directory.\n"));
@@ -651,7 +641,7 @@
}
/* Read in all objects: */
- list = read_objects(layer_node, objects_hash, filename, NULL);
+ list = read_objects(layer_node, objects_hash, filename, NULL, unknown_objects_hash);
layer_add_objects (layer, list);
read_connections( list, layer_node, objects_hash);
@@ -683,7 +673,17 @@
"A valid Dia file defines at least one layer."),
dia_message_filename(filename));
return FALSE;
+ } else if (0 < g_hash_table_size(unknown_objects_hash)) {
+ GString* unknown_str = g_string_new("Unknown types while reading diagram file");
+
+ /* show all the unknown types in one message */
+ g_hash_table_foreach(unknown_objects_hash,
+ GHFuncUnknownObjects,
+ unknown_str);
+ message_warning("%s", unknown_str->str);
+ g_string_free(unknown_str, TRUE);
}
+ g_hash_table_destroy(unknown_objects_hash);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]