X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-root.cpp;h=94b561bcce3c3433a09c443afa01e01035c1aa49;hb=9e973c4fb2183b877bb600a7e9c75e93b3e7d6d1;hp=d6e423edcabf53582627a1fdbc18fdaa5bae5552;hpb=3caca4f8381f7ae35678d16074c2414c02a0c0ff;p=inkscape.git diff --git a/src/sp-root.cpp b/src/sp-root.cpp index d6e423edc..94b561bcc 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -13,7 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include "svg/svg.h" #include "display/nr-arena-group.h" @@ -43,7 +48,7 @@ static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, In static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_root_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_root_modified(SPObject *object, guint flags); -static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); +static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); @@ -123,7 +128,7 @@ sp_root_init(SPRoot *root) root->width.unset(SVGLength::PERCENT, 1.0, 1.0); root->height.unset(SVGLength::PERCENT, 1.0, 1.0); - /* nr_matrix_set_identity(&root->viewbox); */ + /* root->viewbox.set_identity(); */ root->viewBox_set = FALSE; root->c2p.set_identity(); @@ -353,9 +358,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 node - it is not beautiful, but works */ for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) { @@ -572,12 +577,11 @@ sp_root_modified(SPObject *object, guint flags) * Writes the object into the repr object, then calls the parent's write routine. */ static Inkscape::XML::Node * -sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +sp_root_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPRoot *root = SP_ROOT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); repr = xml_doc->createElement("svg:svg"); } @@ -606,7 +610,7 @@ sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) } if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write(object, repr, flags); + ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); return repr; }