Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / box3d-context.cpp
index 4146ec30df4e2afcca52c28a0c800ba6c1bfb3fc..e3476deb3a00aec82ab547d3c56a08e73a504fd0 100644 (file)
@@ -185,7 +185,7 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g
 
 /* create a default perspective in document defs if none is present
    (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */
-static void sp_box3d_context_check_for_persp_in_defs(Document *document) {
+static void sp_box3d_context_check_for_persp_in_defs(SPDocument *document) {
     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
 
     bool has_persp = false;
@@ -561,7 +561,7 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
         }
 
         /* Create object */
-        Inkscape::XML::DocumentTree *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
         Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
         repr->setAttribute("sodipodi:type", "inkscape:box3d");
 
@@ -625,10 +625,14 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
 static void sp_box3d_finish(Box3DContext *bc)
 {
     bc->_message_context->clear();
-    g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
+    bc->ctrl_dragged = false;
+    bc->extruded = false;
 
     if ( bc->item != NULL ) {
         SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
+        SPDocument *doc = sp_desktop_document(desktop);
+        if (!doc || !doc->current_persp3d)
+            return;
 
         SPBox3D *box = SP_BOX3D(bc->item);
 
@@ -647,9 +651,6 @@ static void sp_box3d_finish(Box3DContext *bc)
 
         bc->item = NULL;
     }
-
-    bc->ctrl_dragged = false;
-    bc->extruded = false;
 }
 
 void sp_box3d_context_update_lines(SPEventContext *ec) {