summaryrefslogtreecommitdiffstats
path: root/src/xml/helper-observer.cpp
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2014-07-19 21:22:12 +0000
committer~suv <suv-sf@users.sourceforge.net>2014-07-19 21:22:12 +0000
commitdb8282d8518263885625d9c19aefad1bdbb175d4 (patch)
tree911a397de0ac4588c2475e6bc3d9310ad3e92d2a /src/xml/helper-observer.cpp
parentupdate to trunk (r13425) (diff)
parentWarnings cleaup. (diff)
downloadinkscape-db8282d8518263885625d9c19aefad1bdbb175d4.tar.gz
inkscape-db8282d8518263885625d9c19aefad1bdbb175d4.zip
update to trunk (r13454)
(bzr r13398.1.4)
Diffstat (limited to 'src/xml/helper-observer.cpp')
-rw-r--r--src/xml/helper-observer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/xml/helper-observer.cpp b/src/xml/helper-observer.cpp
index c54dd8e74..957f3df0a 100644
--- a/src/xml/helper-observer.cpp
+++ b/src/xml/helper-observer.cpp
@@ -5,25 +5,34 @@ namespace XML {
// Very simple observer that just emits a signal if anything happens to a node
SignalObserver::SignalObserver()
- : _oldsel(0)
+ : _oldsel(NULL)
{}
+SignalObserver::~SignalObserver()
+{
+ set(NULL); // if _oldsel!=nullptr, remove observer and decrease refcount
+}
+
// Add this observer to the SPObject and remove it from any previous object
void SignalObserver::set(SPObject* o)
{
// XML Tree being used direcly in this function in the following code
// while it shouldn't be
+ // Pointer to object is stored, so refcounting should be increased/decreased
if(_oldsel) {
if (_oldsel->getRepr()) {
_oldsel->getRepr()->removeObserver(*this);
}
+ sp_object_unref(_oldsel);
+ _oldsel = NULL;
}
if(o) {
if (o->getRepr()) {
o->getRepr()->addObserver(*this);
+ sp_object_ref(o);
+ _oldsel = o;
}
}
- _oldsel = o;
}
void SignalObserver::notifyChildAdded(XML::Node&, XML::Node&, XML::Node*)