diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-26 14:44:07 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-26 14:44:07 +0000 |
| commit | c784e87f3b53e823dfb303e296ede834accc9322 (patch) | |
| tree | d66e298e132dc90693a8e5232a88e02c27edf655 /src/sp-object.cpp | |
| parent | Remove sp_style_new(). (diff) | |
| download | inkscape-c784e87f3b53e823dfb303e296ede834accc9322.tar.gz inkscape-c784e87f3b53e823dfb303e296ede834accc9322.zip | |
SPStyle ref counting clean up.
(bzr r13822.1.7)
Diffstat (limited to 'src/sp-object.cpp')
| -rw-r--r-- | src/sp-object.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 4f213f943..059fa8093 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -146,7 +146,18 @@ SPObject::~SPObject() { this->_successor = NULL; } - delete this->style; + if( style == NULL ) { + // style pointer could be NULL if unreffed too many times. + // 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; + sp_style_unref( this->style ); + } else { + delete this->style; + } } // CPPIFY: make pure virtual @@ -798,9 +809,10 @@ void SPObject::releaseReferences() { g_assert(!this->id); } - if (this->style) { - this->style = sp_style_unref(this->style); - } + // style belongs to SPObject, we should not need to unref here. + // if (this->style) { + // this->style = sp_style_unref(this->style); + // } this->document = NULL; this->repr = NULL; |
