diff options
| author | su_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 |
| commit | db8282d8518263885625d9c19aefad1bdbb175d4 (patch) | |
| tree | 911a397de0ac4588c2475e6bc3d9310ad3e92d2a /src/xml | |
| parent | update to trunk (r13425) (diff) | |
| parent | Warnings cleaup. (diff) | |
| download | inkscape-db8282d8518263885625d9c19aefad1bdbb175d4.tar.gz inkscape-db8282d8518263885625d9c19aefad1bdbb175d4.zip | |
update to trunk (r13454)
(bzr r13398.1.4)
Diffstat (limited to 'src/xml')
| -rw-r--r-- | src/xml/helper-observer.cpp | 13 | ||||
| -rw-r--r-- | src/xml/helper-observer.h | 1 |
2 files changed, 12 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*) diff --git a/src/xml/helper-observer.h b/src/xml/helper-observer.h index e7881cd4d..2f70ba792 100644 --- a/src/xml/helper-observer.h +++ b/src/xml/helper-observer.h @@ -17,6 +17,7 @@ namespace Inkscape { { public: SignalObserver(); + ~SignalObserver(); // Add this observer to the SPObject and remove it from any previous object void set(SPObject* o); |
