Code

fix 1654495: a comment repr node has no spobject, so we must weaken the asserts
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 11 Feb 2007 02:00:45 +0000 (02:00 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 11 Feb 2007 02:00:45 +0000 (02:00 +0000)
src/sp-object.cpp
src/sp-root.cpp

index 9294a2e9f442c9f83f6f9bbc1f2c49587139b56c..9b6c249172b18839ebd50548171d2c55132f08a4 100644 (file)
@@ -737,8 +737,9 @@ sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child)
 {
     debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
     SPObject *ochild = sp_object_get_child_by_repr(object, child);
-    g_return_if_fail(ochild != NULL);
-    sp_object_detach(object, ochild);
+    g_return_if_fail (ochild != NULL || !strcmp("comment", child->name())); // comments have no objects
+    if (ochild)
+        sp_object_detach(object, ochild);
 }
 
 /**
index d6e423edcabf53582627a1fdbc18fdaa5bae5552..c555c78a00bce3c97f12f468225fcad3730b8d93 100644 (file)
@@ -353,9 +353,9 @@ sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML:
         (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref);
 
     SPObject *co = object->document->getObjectByRepr(child);
-    g_assert(co != NULL);
+    g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object
 
-    if (SP_IS_DEFS(co)) {
+    if (co && SP_IS_DEFS(co)) {
         SPObject *c;
         /* We search for first <defs> node - it is not beautiful, but works */
         for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) {