Code

Patch from Debian bug tracker from Daniel Kahn Gillmor
[inkscape.git] / src / sp-offset.cpp
index fc9115f24adadbacc7f3af3c1475df4cc962beb4..74382b7681ba9f1409b63489fbb9c7f94976c005 100644 (file)
@@ -179,6 +179,7 @@ sp_offset_init(SPOffset *offset)
     offset->sourceHref = NULL;
     offset->sourceRepr = NULL;
     offset->sourceObject = NULL;
+    new (&offset->_modified_connection) sigc::connection();
     new (&offset->_delete_connection) sigc::connection();
     new (&offset->_changed_connection) sigc::connection();
     new (&offset->_transformed_connection) sigc::connection();
@@ -196,8 +197,14 @@ sp_offset_finalize(GObject *obj)
     SPOffset *offset = (SPOffset *) obj;
 
     delete offset->sourceRef;
+
+    offset->_modified_connection.disconnect();
+    offset->_modified_connection.~connection();
+    offset->_delete_connection.disconnect();
     offset->_delete_connection.~connection();
+    offset->_changed_connection.disconnect();
     offset->_changed_connection.~connection();
+    offset->_transformed_connection.disconnect();
     offset->_transformed_connection.~connection();
 }
 
@@ -255,7 +262,8 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     SPOffset *offset = SP_OFFSET (object);
 
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new ("svg:path");
+        Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(object)->document();
+        repr = xml_doc->createElement("svg:path");
     }
 
     if (flags & SP_OBJECT_WRITE_EXT) {
@@ -277,7 +285,7 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     }
 
     // write that curve to "d"
-    char *d = sp_svg_write_path (((SPShape *) offset)->curve->bpath);
+    char *d = sp_svg_write_path (SP_CURVE_BPATH(((SPShape *) offset)->curve));
     repr->setAttribute("d", d);
     g_free (d);
 
@@ -346,7 +354,7 @@ sp_offset_set(SPObject *object, unsigned key, gchar const *value)
                 bpath = sp_svg_read_path (offset->original);
                 curve = sp_curve_new_from_bpath (bpath);       // curve se chargera de detruire bpath
                 g_assert (curve != NULL);
-                offset->originalPath = bpath_to_liv_path (curve->bpath);
+                offset->originalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
                 sp_curve_unref (curve);
 
                 offset->knotSet = false;
@@ -1023,7 +1031,7 @@ sp_offset_top_point (SPOffset * offset, NR::Point *px)
             return;
     }
 
-    Path *finalPath = bpath_to_liv_path (curve->bpath);
+    Path *finalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
     if (finalPath == NULL)
     {
         sp_curve_unref (curve);
@@ -1057,7 +1065,7 @@ static void sp_offset_start_listening(SPOffset *offset,SPObject* to)
 
     offset->_delete_connection = SP_OBJECT(to)->connectDelete(sigc::bind(sigc::ptr_fun(&sp_offset_delete_self), offset));
     offset->_transformed_connection = SP_ITEM(to)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_offset_move_compensate), offset));
-    offset->_modified_connection = g_signal_connect (G_OBJECT (to), "modified", G_CALLBACK (sp_offset_source_modified), offset);
+    offset->_modified_connection = SP_OBJECT(to)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_offset_source_modified), offset));
 }
 
 static void sp_offset_quit_listening(SPOffset *offset)
@@ -1065,7 +1073,7 @@ static void sp_offset_quit_listening(SPOffset *offset)
     if ( offset->sourceObject == NULL )
         return;
 
-    g_signal_handler_disconnect (offset->sourceObject, offset->_modified_connection);
+    offset->_modified_connection.disconnect();
     offset->_delete_connection.disconnect();
     offset->_transformed_connection.disconnect();
 
@@ -1167,7 +1175,7 @@ refresh_offset_source(SPOffset* offset)
         if (curve == NULL)
            return;
     }
-    orig = bpath_to_liv_path (curve->bpath);
+    orig = bpath_to_liv_path (SP_CURVE_BPATH(curve));
     sp_curve_unref (curve);