summaryrefslogtreecommitdiffstats
path: root/src/sp-object.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:16:36 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:16:36 +0000
commit913372144fbee834867176885a5526d70243e4e0 (patch)
treea28957014d44a50067932243cc919f522efac898 /src/sp-object.cpp
parentupdate to trunk (diff)
parentLatvian translation update (diff)
downloadinkscape-913372144fbee834867176885a5526d70243e4e0.tar.gz
inkscape-913372144fbee834867176885a5526d70243e4e0.zip
update to trunk
(bzr r13682.1.23)
Diffstat (limited to 'src/sp-object.cpp')
-rw-r--r--src/sp-object.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 059fa8093..343db435e 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -61,14 +61,6 @@ using std::strstr;
# define debug(f, a...) /* */
#endif
-namespace {
- SPObject* createObject() {
- return new SPObject();
- }
-
- bool gridRegistered = SPFactory::instance().registerObject("inkscape:grid", createObject);
-}
-
guint update_in_progress = 0; // guard against update-during-update
Inkscape::XML::NodeEventVector object_event_vector = {
@@ -115,7 +107,7 @@ static gchar *sp_object_get_unique_id(SPObject *object,
SPObject::SPObject()
: cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0),
document(NULL), parent(NULL), children(NULL), _last_child(NULL),
- next(NULL), id(NULL), repr(NULL), refCount(1),
+ next(NULL), id(NULL), repr(NULL), refCount(1),hrefList(std::list<SPObject*>()),
_successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT),
_label(NULL), _default_label(NULL)
{
@@ -151,9 +143,14 @@ SPObject::~SPObject() {
// Conjecture: style pointer is never NULL.
std::cerr << "SPObject::~SPObject(): style pointer is NULL" << std::endl;
} else if( style->refCount() > 1 ) {
- // Several classes ref style.
// Conjecture: style pointer should be unreffed by other classes before reaching here.
- std::cerr << "SPObject::~SPObject(): someone else still holding ref to style" << std::endl;
+ // Conjecture is false for SPTSpan where ref is held by InputStreamTextSource.
+ // As an additional note:
+ // The outer tspan of a nested tspan will result in a ref count of five: one for the
+ // TSpan itself, one for the InputStreamTextSource instance before the inner tspan and
+ // one for the one after, along with one for each corresponding DrawingText instance.
+ // std::cerr << "SPObject::~SPObject(): someone else still holding ref to style" << std::endl;
+ //
sp_style_unref( this->style );
} else {
delete this->style;
@@ -249,7 +246,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner)
return NULL;
}
-SPObject *sp_object_href(SPObject *object, gpointer /*owner*/)
+SPObject *sp_object_href(SPObject *object, SPObject* owner)
{
g_return_val_if_fail(object != NULL, NULL);
g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -257,10 +254,13 @@ SPObject *sp_object_href(SPObject *object, gpointer /*owner*/)
object->hrefcount++;
object->_updateTotalHRefCount(1);
+ if(owner)
+ object->hrefList.push_front(owner);
+
return object;
}
-SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/)
+SPObject *sp_object_hunref(SPObject *object, SPObject* owner)
{
g_return_val_if_fail(object != NULL, NULL);
g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -269,6 +269,9 @@ SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/)
object->hrefcount--;
object->_updateTotalHRefCount(-1);
+ if(owner)
+ object->hrefList.remove(owner);
+
return NULL;
}
@@ -618,7 +621,7 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
const std::string type_string = NodeTraits::get_type_string(*child);
- SPObject* ochild = SPFactory::instance().createObject(type_string);
+ SPObject* ochild = SPFactory::createObject(type_string);
if (ochild == NULL) {
// Currenty, there are many node types that do not have
// corresponding classes in the SPObject tree.
@@ -677,7 +680,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) {
for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) {
const std::string typeString = NodeTraits::get_type_string(*rchild);
- SPObject* child = SPFactory::instance().createObject(typeString);
+ SPObject* child = SPFactory::createObject(typeString);
if (child == NULL) {
// Currenty, there are many node types that do not have
// corresponding classes in the SPObject tree.