From 01616ad9d6084dc6ef4fc14622b018ee582431d2 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sat, 14 Jul 2007 14:51:56 +0000 Subject: Write distinguished corners of 3D boxes to the svg representation from which the box can be recomputed. This is used to fix several bugs related to the editing of boxes resulting from cloning, undo operations or newly opened documents (we had stray pointers to SPPaths before that made Inkscape crash). (bzr r3239) --- src/box3d-face.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/box3d-face.cpp') diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp index 02c84e22c..2cb510277 100644 --- a/src/box3d-face.cpp +++ b/src/box3d-face.cpp @@ -162,19 +162,27 @@ NR::Point Box3DFace::operator[](unsigned int i) * Append the curve's path as a child to the given 3D box (since SP3DBox * is derived from SPGroup, so we can append children to its svg representation) */ -void Box3DFace::hook_path_to_3dbox() +void Box3DFace::hook_path_to_3dbox(SPPath * existing_path) { - if (this->path) return; // This test can probably be removed. + if (this->path) { + //g_print ("Path already exists. Returning ...\n"); + return; + } + + if (existing_path != NULL) { + // no need to create a new path + this->path = existing_path; + return; + } SPDesktop *desktop = inkscape_active_desktop(); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(inkscape_active_event_context())); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(SP_OBJECT(parent_box3d))); GString *pstring = g_string_new(""); g_string_printf (pstring, "tools.shapes.3dbox.%s", axes_string()); Inkscape::XML::Node *repr_face = xml_doc->createElement("svg:path"); sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false); this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face)); - Inkscape::GC::release(repr_face); } -- cgit v1.2.3