summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-01-06 18:31:47 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-01-06 18:31:47 +0000
commit222f1936586214bc889b7c079757cea005980657 (patch)
tree7be9ef5572e633af419d45268155bfc407a599f7 /src/document.cpp
parentMerge branch 'patch-1' of gitlab.com:tobiczech/inkscape (diff)
downloadinkscape-222f1936586214bc889b7c079757cea005980657.tar.gz
inkscape-222f1936586214bc889b7c079757cea005980657.zip
Remove unneeded unreferencing. Add check on reference count.
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/document.cpp b/src/document.cpp
index a2d7a32cb..3daae3deb 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -102,6 +102,7 @@ SPDocument::SPDocument() :
root(nullptr),
style_cascade(cr_cascade_new(nullptr, nullptr, nullptr)),
style_sheet(nullptr),
+ ref_count(0),
uri(nullptr),
base(nullptr),
name(nullptr),
@@ -594,12 +595,19 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un
SPDocument *SPDocument::doRef()
{
+ ++ref_count;
+ // std::cout << "SPDocument::doRef() " << ref_count << " " << this << std::endl;
Inkscape::GC::anchor(this);
return this;
}
SPDocument *SPDocument::doUnref()
{
+ --ref_count;
+ if (ref_count < 0) {
+ std::cerr << "SPDocument::doUnref(): invalid ref count! " << ref_count << std::endl;
+ }
+ // std::cout << "SPDocument::doUnref() " << ref_count << " " << this << std::endl;
Inkscape::GC::release(this);
return nullptr;
}