Code

CodingStyle: const placement
[inkscape.git] / src / document.cpp
index f69c480f75e4a3f108cfdc9ce792283d166a3d4f..c5fa71f2be0c1c0f6f3220655e3976fc3b301c0f 100644 (file)
@@ -18,7 +18,7 @@
 /** \class SPDocument
  * SPDocument serves as the container of both model trees (agnostic XML
  * and typed object tree), and implements all of the document-level
- * functionality used by the program. Many document level operations, like 
+ * functionality used by the program. Many document level operations, like
  * load, save, print, export and so on, use SPDocument as their basic datatype.
  *
  * SPDocument implements undo and redo stacks and an id-based object
@@ -50,6 +50,7 @@
 #include "dir-util.h"
 #include "unit-constants.h"
 #include "prefs-utils.h"
+#include "libavoid/router.h"
 
 #include "display/nr-arena-item.h"
 
@@ -86,6 +87,9 @@ SPDocument::SPDocument() {
 
     _collection_queue = NULL;
 
+    // Initialise instance of connector router.
+    router = new Avoid::Router();
+
     p = new SPDocumentPrivate();
 
     p->iddef = g_hash_table_new(g_direct_hash, g_direct_equal);
@@ -164,6 +168,11 @@ SPDocument::~SPDocument() {
         keepalive = FALSE;
     }
 
+    if (router) {
+        delete router;
+        router = NULL;
+    }
+
     //delete this->_whiteboard_session_manager;
 }
 
@@ -192,7 +201,7 @@ void SPDocument::reset_key (void *dummy)
 {
     actionkey = NULL;
 }
-    
+
 static SPDocument *
 sp_document_create(Inkscape::XML::Document *rdoc,
                    gchar const *uri,
@@ -307,7 +316,7 @@ sp_document_create(Inkscape::XML::Document *rdoc,
 }
 
 /**
- * Fetches document from URI, or creates new, if NULL; public document 
+ * Fetches document from URI, or creates new, if NULL; public document
  * appears in document list.
  */
 SPDocument *
@@ -986,6 +995,9 @@ sp_document_remove_resource(SPDocument *document, gchar const *key, SPObject *ob
     g_return_val_if_fail(object != NULL, FALSE);
     g_return_val_if_fail(SP_IS_OBJECT(object), FALSE);
 
+    if (SP_OBJECT_IS_CLONED(object))
+        return FALSE;
+
     rlist = (GSList*)g_hash_table_lookup(document->priv->resources, key);
     g_return_val_if_fail(rlist != NULL, FALSE);
     g_return_val_if_fail(g_slist_find(rlist, object), FALSE);