From fd0a5dfa4cb237f8e5232c785693cc3e676336e8 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 2 Sep 2012 21:32:59 +0200 Subject: converted some c-string usage to c++ string class usage: should fix some memory leaks (bzr r11646) --- src/sp-object.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 892c89a15..9ceeaf262 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1031,15 +1031,9 @@ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inksca if( prefs->getBool("/options/svgoutput/check_on_editing") ) { unsigned int flags = sp_attribute_clean_get_prefs(); - gchar *s_cleaned = sp_attribute_clean_style( repr, s, flags ); - - // g_warning("SPObject::sp_object_private_write: %s", object->getId() ); - // g_warning(" old: :%s:", repr->attribute("style") ); - // g_warning(" new: :%s:", s ); - // g_warning(" cleaned: :%s:", s_cleaned ); - + Glib::ustring s_cleaned = sp_attribute_clean_style( repr, s, flags ); g_free( s ); - s = s_cleaned; + s = (s_cleaned.empty() ? NULL : g_strdup (s_cleaned.c_str())); } if( s == NULL || strcmp(s,"") == 0 ) { -- cgit v1.2.3 From d4f5006264e2e19a9fe50968a2e422b83785821c Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 3 Sep 2012 08:35:01 +0200 Subject: revert rev 11646: build issue with dbus (forgot to adapt some more, dbus was not enabled) and other issues (bzr r11649) --- src/sp-object.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 9ceeaf262..892c89a15 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1031,9 +1031,15 @@ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inksca if( prefs->getBool("/options/svgoutput/check_on_editing") ) { unsigned int flags = sp_attribute_clean_get_prefs(); - Glib::ustring s_cleaned = sp_attribute_clean_style( repr, s, flags ); + gchar *s_cleaned = sp_attribute_clean_style( repr, s, flags ); + + // g_warning("SPObject::sp_object_private_write: %s", object->getId() ); + // g_warning(" old: :%s:", repr->attribute("style") ); + // g_warning(" new: :%s:", s ); + // g_warning(" cleaned: :%s:", s_cleaned ); + g_free( s ); - s = (s_cleaned.empty() ? NULL : g_strdup (s_cleaned.c_str())); + s = s_cleaned; } if( s == NULL || strcmp(s,"") == 0 ) { -- cgit v1.2.3 From bac4df147de363a0774548acd63d367a09ab50d3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 20 Sep 2012 22:40:55 +0200 Subject: some memleak fixes (Bug #1043571) (bzr r11686) --- src/sp-object.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 892c89a15..9ceeaf262 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1031,15 +1031,9 @@ Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inksca if( prefs->getBool("/options/svgoutput/check_on_editing") ) { unsigned int flags = sp_attribute_clean_get_prefs(); - gchar *s_cleaned = sp_attribute_clean_style( repr, s, flags ); - - // g_warning("SPObject::sp_object_private_write: %s", object->getId() ); - // g_warning(" old: :%s:", repr->attribute("style") ); - // g_warning(" new: :%s:", s ); - // g_warning(" cleaned: :%s:", s_cleaned ); - + Glib::ustring s_cleaned = sp_attribute_clean_style( repr, s, flags ); g_free( s ); - s = s_cleaned; + s = (s_cleaned.empty() ? NULL : g_strdup (s_cleaned.c_str())); } if( s == NULL || strcmp(s,"") == 0 ) { -- cgit v1.2.3 From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/sp-object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 9ceeaf262..c16dbaeef 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -339,7 +339,7 @@ SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const { return longest_common_suffix(this, object, NULL, &same_objects); } -SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { +static SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { SPObject const *result = 0; if ( obj && ancestor ) { if (obj->parent == ancestor) { -- cgit v1.2.3 From f304ab600788b02cb02a4413f68f466e35cf1539 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 11 Oct 2012 19:54:14 +0200 Subject: Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog (bzr r11782) --- src/sp-object.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c16dbaeef..3e18c0835 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1409,6 +1409,9 @@ void SPObject::_requireSVGVersion(Inkscape::Version version) { be made. The same applies to 'desc' elements. Therefore, these functions ignore all but the first 'title' child element and first 'desc' child element, except when deleting a title or description. + + This will change in SVG 2, where multiple 'title' and 'desc' elements will + be allowed with different localized strings. */ gchar * SPObject::title() const -- cgit v1.2.3 From f2907ae896ed8688e800519310b61754550f27f6 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 14:17:53 +0000 Subject: SPObject: drop sp_object_ prefix on class members (bzr r11869) --- src/sp-object.cpp | 71 ++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 3e18c0835..2cf28137a 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -64,11 +64,11 @@ using std::strstr; guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { - SPObject::sp_object_repr_child_added, - SPObject::sp_object_repr_child_removed, - SPObject::sp_object_repr_attr_changed, - SPObject::sp_object_repr_content_changed, - SPObject::sp_object_repr_order_changed + SPObject::repr_child_added, + SPObject::repr_child_removed, + SPObject::repr_attr_changed, + SPObject::repr_content_changed, + SPObject::repr_order_changed }; // A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API @@ -104,18 +104,18 @@ public: GObjectClass * SPObjectClass::static_parent_class = 0; -GType SPObject::sp_object_get_type() +GType SPObject::get_type() { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPObjectClass), NULL, NULL, - (GClassInitFunc) SPObjectClass::sp_object_class_init, + (GClassInitFunc) SPObjectClass::init, NULL, NULL, sizeof(SPObject), 16, - (GInstanceInitFunc) sp_object_init, + (GInstanceInitFunc)init, NULL }; type = g_type_register_static(G_TYPE_OBJECT, "SPObject", &info, (GTypeFlags)0); @@ -123,7 +123,7 @@ GType SPObject::sp_object_get_type() return type; } -void SPObjectClass::sp_object_class_init(SPObjectClass *klass) +void SPObjectClass::init(SPObjectClass *klass) { GObjectClass *object_class; @@ -131,21 +131,18 @@ void SPObjectClass::sp_object_class_init(SPObjectClass *klass) static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); - object_class->finalize = SPObject::sp_object_finalize; + object_class->finalize = SPObject::finalize; - klass->child_added = SPObject::sp_object_child_added; - klass->remove_child = SPObject::sp_object_remove_child; - klass->order_changed = SPObject::sp_object_order_changed; - - klass->release = SPObject::sp_object_release; - - klass->build = SPObject::sp_object_build; - - klass->set = SPObject::sp_object_private_set; - klass->write = SPObject::sp_object_private_write; + klass->child_added = SPObject::child_added; + klass->remove_child = SPObject::remove_child; + klass->order_changed = SPObject::order_changed; + klass->release = SPObject::release; + klass->build = SPObject::build; + klass->set = SPObject::private_set; + klass->write = SPObject::private_write; } -void SPObject::sp_object_init(SPObject *object) +void SPObject::init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@ -178,7 +175,7 @@ void SPObject::sp_object_init(SPObject *object) object->_default_label = NULL; } -void SPObject::sp_object_finalize(GObject *object) +void SPObject::finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@ -616,7 +613,7 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) return result; } -void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +void SPObject::child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); if (!type) { @@ -630,7 +627,7 @@ void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *chil ochild->invoke_build(object->document, child, object->cloned); } -void SPObject::sp_object_release(SPObject *object) +void SPObject::release(SPObject *object) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); while (object->children) { @@ -638,7 +635,7 @@ void SPObject::sp_object_release(SPObject *object) } } -void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) +void SPObject::remove_child(SPObject *object, Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); SPObject *ochild = object->get_child_by_repr(child); @@ -648,7 +645,7 @@ void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *chi } } -void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/, +void SPObject::order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node * /*old_ref*/, Inkscape::XML::Node *new_ref) { SPObject *ochild = object->get_child_by_repr(child); @@ -658,7 +655,7 @@ void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *ch ochild->_position_changed_signal.emit(ochild); } -void SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +void SPObject::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Nothing specific here */ debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@ -709,7 +706,7 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns gchar const *id = this->repr->attribute("id"); if (!document->isSeeking()) { { - gchar *realid = sp_object_get_unique_id(this, id); + gchar *realid = get_unique_id(this, id); g_assert(realid != NULL); this->document->bindObjectToId(realid, this); @@ -820,7 +817,7 @@ SPObject *SPObject::getPrev() return prev; } -void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) +void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -829,7 +826,7 @@ void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscap } } -void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) +void SPObject::repr_child_removed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node * /*ref*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -838,7 +835,7 @@ void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inksc } } -void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) +void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -847,7 +844,7 @@ void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inksc } } -void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) +void SPObject::private_set(SPObject *object, unsigned int key, gchar const *value) { g_assert(key != SP_ATTR_INVALID); @@ -869,7 +866,7 @@ void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar c if (!document->isSeeking()) { sp_object_ref(conflict, NULL); // give the conflicting object a new ID - gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL); + gchar *new_conflict_id = get_unique_id(conflict, NULL); conflict->getRepr()->setAttribute("id", new_conflict_id); g_free(new_conflict_id); sp_object_unref(conflict, NULL); @@ -960,7 +957,7 @@ void SPObject::readAttr(gchar const *key) } } -void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) +void SPObject::repr_attr_changed(Inkscape::XML::Node * /*repr*/, gchar const *key, gchar const * /*oldval*/, gchar const * /*newval*/, bool is_interactive, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -973,7 +970,7 @@ void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar } } -void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) +void SPObject::repr_content_changed(Inkscape::XML::Node * /*repr*/, gchar const * /*oldcontent*/, gchar const * /*newcontent*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -997,7 +994,7 @@ static gchar const *sp_xml_get_space_string(unsigned int space) } } -Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * SPObject::private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { repr = object->getRepr()->duplicate(doc); @@ -1302,7 +1299,7 @@ bool SPObject::storeAsDouble( gchar const *key, double *val ) const /* Helper */ -gchar * SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) +gchar * SPObject::get_unique_id(SPObject *object, gchar const *id) { static unsigned long count = 0; -- cgit v1.2.3 From cd0794c0d76a46a0ae47b6c450167015ee41bc35 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 17 Jan 2013 00:59:37 +0000 Subject: Cleanup more GObject type definitions (bzr r12034) --- src/sp-object.cpp | 184 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 134 insertions(+), 50 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 2cf28137a..4d2a5a709 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -101,48 +101,63 @@ public: } }; +static void sp_object_child_added(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node *ref); -GObjectClass * SPObjectClass::static_parent_class = 0; +static void sp_object_finalize(GObject *object); -GType SPObject::get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPObjectClass), - NULL, NULL, - (GClassInitFunc) SPObjectClass::init, - NULL, NULL, - sizeof(SPObject), - 16, - (GInstanceInitFunc)init, - NULL - }; - type = g_type_register_static(G_TYPE_OBJECT, "SPObject", &info, (GTypeFlags)0); - } - return type; -} - -void SPObjectClass::init(SPObjectClass *klass) -{ - GObjectClass *object_class; +static void sp_object_remove_child(SPObject *object, + Inkscape::XML::Node *child); + +static void sp_object_order_changed(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node *old_ref, + Inkscape::XML::Node *new_ref); - object_class = (GObjectClass *) klass; +static void sp_object_release(SPObject *object); +static void sp_object_build(SPObject *object, + SPDocument *document, + Inkscape::XML::Node *repr); - static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); +static void sp_object_private_set(SPObject *object, + unsigned int key, + gchar const *value); - object_class->finalize = SPObject::finalize; +static Inkscape::XML::Node *sp_object_private_write(SPObject *object, + Inkscape::XML::Document *doc, + Inkscape::XML::Node *repr, + guint flags); + +static gchar *sp_object_get_unique_id(SPObject *object, + gchar const *defid); + +G_DEFINE_TYPE(SPObject, sp_object, G_TYPE_OBJECT); + +/** + * Initializes the SPObject vtable. + */ +static void +sp_object_class_init(SPObjectClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->finalize = sp_object_finalize; - klass->child_added = SPObject::child_added; - klass->remove_child = SPObject::remove_child; - klass->order_changed = SPObject::order_changed; - klass->release = SPObject::release; - klass->build = SPObject::build; - klass->set = SPObject::private_set; - klass->write = SPObject::private_write; + klass->child_added = sp_object_child_added; + klass->remove_child = sp_object_remove_child; + klass->order_changed = sp_object_order_changed; + klass->release = sp_object_release; + klass->build = sp_object_build; + klass->set = sp_object_private_set; + klass->write = sp_object_private_write; } -void SPObject::init(SPObject *object) +/** + * Callback to initialize the SPObject object. + */ +static void +sp_object_init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@ -175,7 +190,11 @@ void SPObject::init(SPObject *object) object->_default_label = NULL; } -void SPObject::finalize(GObject *object) +/** + * Callback to destroy all members and connections of object and itself. + */ +static void +sp_object_finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@ -194,8 +213,8 @@ void SPObject::finalize(GObject *object) spobject->_delete_signal.~signal(); spobject->_position_changed_signal.~signal(); - if (((GObjectClass *) (SPObjectClass::static_parent_class))->finalize) { - (* ((GObjectClass *) (SPObjectClass::static_parent_class))->finalize)(object); + if (((GObjectClass *) (sp_object_parent_class))->finalize) { + (* ((GObjectClass *) (sp_object_parent_class))->finalize)(object); } } @@ -613,7 +632,14 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) return result; } -void SPObject::child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +/** + * Callback for child_added event. + * Invoked whenever the given mutation event happens in the XML tree. + */ +static void +sp_object_child_added(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); if (!type) { @@ -627,7 +653,19 @@ void SPObject::child_added(SPObject *object, Inkscape::XML::Node *child, Inkscap ochild->invoke_build(object->document, child, object->cloned); } -void SPObject::release(SPObject *object) +/** + * Removes, releases and unrefs all children of object. + * + * This is the opposite of build. It has to be invoked as soon as the + * object is removed from the tree, even if it is still alive according + * to reference count. The frontend unregisters the object from the + * document and releases the SPRepr bindings; implementations should free + * state data and release all child objects. Invoking release on + * SPRoot destroys the whole document tree. + * @see sp_object_build() + */ +static void +sp_object_release(SPObject *object) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); while (object->children) { @@ -635,7 +673,17 @@ void SPObject::release(SPObject *object) } } -void SPObject::remove_child(SPObject *object, Inkscape::XML::Node *child) +/** + * Remove object's child whose node equals repr, release and + * unref it. + * + * Invoked whenever the given mutation event happens in the XML + * tree, BEFORE removal from the XML tree happens, so grouping + * objects can safely release the child data. + */ +static void +sp_object_remove_child(SPObject *object, + Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); SPObject *ochild = object->get_child_by_repr(child); @@ -645,8 +693,17 @@ void SPObject::remove_child(SPObject *object, Inkscape::XML::Node *child) } } -void SPObject::order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node * /*old_ref*/, - Inkscape::XML::Node *new_ref) +/** + * Move object corresponding to child after sibling object corresponding + * to new_ref. + * Invoked whenever the given mutation event happens in the XML tree. + * @param old_ref Ignored + */ +static void +sp_object_order_changed(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node * /*old_ref*/, + Inkscape::XML::Node *new_ref) { SPObject *ochild = object->get_child_by_repr(child); g_return_if_fail(ochild != NULL); @@ -655,7 +712,21 @@ void SPObject::order_changed(SPObject *object, Inkscape::XML::Node *child, Inksc ochild->_position_changed_signal.emit(ochild); } -void SPObject::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +/** + * Virtual build callback. + * + * This has to be invoked immediately after creation of an SPObject. The + * frontend method ensures that the new object is properly attached to + * the document and repr; implementation then will parse all of the attributes, + * generate the children objects and so on. Invoking build on the SPRoot + * object results in creation of the whole document tree (this is, what + * SPDocument does after the creation of the XML tree). + * @see release() + */ +static void +sp_object_build(SPObject *object, + SPDocument *document, + Inkscape::XML::Node *repr) { /* Nothing specific here */ debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@ -706,7 +777,7 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns gchar const *id = this->repr->attribute("id"); if (!document->isSeeking()) { { - gchar *realid = get_unique_id(this, id); + gchar *realid = sp_object_get_unique_id(this, id); g_assert(realid != NULL); this->document->bindObjectToId(realid, this); @@ -844,7 +915,12 @@ void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML: } } -void SPObject::private_set(SPObject *object, unsigned int key, gchar const *value) +/** + * Callback for set event. + */ +static void sp_object_private_set(SPObject *object, + unsigned int key, + gchar const *value) { g_assert(key != SP_ATTR_INVALID); @@ -866,7 +942,7 @@ void SPObject::private_set(SPObject *object, unsigned int key, gchar const *valu if (!document->isSeeking()) { sp_object_ref(conflict, NULL); // give the conflicting object a new ID - gchar *new_conflict_id = get_unique_id(conflict, NULL); + gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL); conflict->getRepr()->setAttribute("id", new_conflict_id); g_free(new_conflict_id); sp_object_unref(conflict, NULL); @@ -994,7 +1070,14 @@ static gchar const *sp_xml_get_space_string(unsigned int space) } } -Inkscape::XML::Node * SPObject::private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +/** + * Callback for write event. + */ +static Inkscape::XML::Node* +sp_object_private_write(SPObject *object, + Inkscape::XML::Document *doc, + Inkscape::XML::Node *repr, + guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { repr = object->getRepr()->duplicate(doc); @@ -1297,9 +1380,10 @@ bool SPObject::storeAsDouble( gchar const *key, double *val ) const return sp_repr_get_double(((Inkscape::XML::Node *)(this->getRepr())),key,val); } -/* Helper */ - -gchar * SPObject::get_unique_id(SPObject *object, gchar const *id) +/** Helper */ +static gchar* +sp_object_get_unique_id(SPObject *object, + gchar const *id) { static unsigned long count = 0; -- cgit v1.2.3