Code

* src/dialogs/layers-panel.cpp: Compile fix from Mathieu Dimanche.
[inkscape.git] / src / conn-avoid-ref.cpp
index df885d44c61717d425bbe5e3c54aeaa153512718..22ddb54250c2a46c2f99ffe63bf1bb888bdad37c 100644 (file)
@@ -74,14 +74,24 @@ void SPAvoidRef::handleSettingChange(void)
     if (desktop == NULL) {
         return;
     }
+    if (sp_desktop_document(desktop) != item->document) {
+        // We don't want to go any further if the active desktop's document
+        // isn't the same as the document that this item is part of.  This
+        // case can happen if a new document is loaded from the file chooser
+        // or via the recent file menu.  In this case, we can end up here
+        // as a rersult of a sp_document_ensure_up_to_date performed on a
+        // document not yet attached to the active desktop.
+        return;
+    }
 
-    Router *router = item->document->router;
-    
     if (new_setting == setting) {
         // Don't need to make any changes
         return;
     }
+    setting = new_setting;
 
+    Router *router = item->document->router;
+    
     _transformed_connection.disconnect();
     if (new_setting) {
         _transformed_connection = item->connectTransformed(
@@ -110,7 +120,6 @@ void SPAvoidRef::handleSettingChange(void)
         router->delShape(shapeRef);
         shapeRef = NULL;
     }
-    setting = new_setting;
 }
 
 
@@ -253,8 +262,7 @@ void avoid_item_move(NR::Matrix const *mp, SPItem *moved_item)
     Router *router = moved_item->document->router;
     Avoid::Polygn poly = avoid_item_poly(moved_item);
     if (poly.pn > 0) {
-        // moveShape actually destroys the old shapeRef and returns a new one.
-        moved_item->avoidRef->shapeRef = router->moveShape(shapeRef, &poly);
+        router->moveShape(shapeRef, &poly);
         Avoid::freePoly(poly);
     }
 }
@@ -264,7 +272,7 @@ void init_avoided_shape_geometry(SPDesktop *desktop)
 {
     // Don't count this as changes to the document,
     // it is basically just llate initialisation.
-    SPDocument *document = SP_DT_DOCUMENT(desktop);
+    SPDocument *document = sp_desktop_document(desktop);
     gboolean saved = sp_document_get_undo_sensitive(document);
     sp_document_set_undo_sensitive(document, FALSE);