summaryrefslogtreecommitdiffstats
path: root/src/box3d-face.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-07-14 14:51:56 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-07-14 14:51:56 +0000
commit01616ad9d6084dc6ef4fc14622b018ee582431d2 (patch)
tree18b19bc71561e666249d6c0021e2700561fa9909 /src/box3d-face.cpp
parentFilter effects dialog: (diff)
downloadinkscape-01616ad9d6084dc6ef4fc14622b018ee582431d2.tar.gz
inkscape-01616ad9d6084dc6ef4fc14622b018ee582431d2.zip
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)
Diffstat (limited to 'src/box3d-face.cpp')
-rw-r--r--src/box3d-face.cpp16
1 files changed, 12 insertions, 4 deletions
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);
}