Code

Fixed to not emit signals from deleted object. May fix 271621.
authorjoncruz <joncruz@users.sourceforge.net>
Wed, 21 Jan 2009 12:53:19 +0000 (12:53 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Wed, 21 Jan 2009 12:53:19 +0000 (12:53 +0000)
Fixed to no longer emit signal from deleted instance. Might fix bug 271621

src/document.cpp
src/document.h

index 5b27272c6ea4e9a034e4743a766b2d6698c45beb..4f54870324b9232fc972ff3897f0ac0b50124826 100644 (file)
@@ -93,7 +93,8 @@ SPDocument::SPDocument() :
     router(new Avoid::Router()),
     perspectives(0),
     current_persp3d(0),
-    _collection_queue(0)
+    _collection_queue(0),
+    oldSignalsConnected(false)
 {
     // Don't use the Consolidate moves optimisation.
     router->ConsolidateMoves = false;
@@ -181,8 +182,14 @@ SPDocument::~SPDocument() {
         modified_id = 0;
     }
 
-    _selection_changed_connection.disconnect();
-    _desktop_activated_connection.disconnect();
+    if (oldSignalsConnected) {
+        g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE),
+                                             reinterpret_cast<gpointer>(sp_document_reset_key),
+                                             static_cast<gpointer>(this));
+    } else {
+        _selection_changed_connection.disconnect();
+        _desktop_activated_connection.disconnect();
+    }
 
     if (keepalive) {
         inkscape_unref();
@@ -385,9 +392,11 @@ sp_document_create(Inkscape::XML::Document *rdoc,
                          G_CALLBACK(sp_document_reset_key), document);
         g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
                          G_CALLBACK(sp_document_reset_key), document);
+        document->oldSignalsConnected = true;
     } else {
         document->_selection_changed_connection = Inkscape::NSApplication::Editor::connectSelectionChanged (sigc::mem_fun (*document, &SPDocument::reset_key));
         document->_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*document, &SPDocument::reset_key));
+        document->oldSignalsConnected = false;
     }
 
     return document;
index 99a887c6bda815406ebd090e0436457a754e0ea5..3ede5a3d0bdc7b4946162b7799595582ca3bec74 100644 (file)
@@ -110,6 +110,8 @@ struct SPDocument : public Inkscape::GC::Managed<>,
 
     GSList *_collection_queue;
 
+    bool oldSignalsConnected;
+
     void add_persp3d (Persp3D * const persp);
     void remove_persp3d (Persp3D * const persp);