summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-05-15 15:33:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-05-22 08:39:54 +0200
commit40a9cb3ba4d63eef736ce449567061a4ffa90714 (patch)
treec96dc4b3f2899e1b773ac75d103ebeefd9341d98 /include
parentupdate groupedbar compact notebookbar add margins and jay feedback (diff)
downloadcore-40a9cb3ba4d63eef736ce449567061a4ffa90714.tar.gz
core-40a9cb3ba4d63eef736ce449567061a4ffa90714.zip
verify that VclPtr properly disposed
Change-Id: Ia76b7ad9e6d7fefaf0088372b5f5fc7dc51c2846 Reviewed-on: https://gerrit.libreoffice.org/37649 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/vcl/vclptr.hxx8
-rw-r--r--include/vcl/vclreferencebase.hxx7
2 files changed, 12 insertions, 3 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index a6dc702675f9..b212fbd42177 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -139,14 +139,16 @@ public:
{
}
-#ifdef DBG_UTIL
-#ifndef WNT
+#if defined(DBG_UTIL) && !defined(WNT)
virtual ~VclPtr()
{
assert(m_rInnerRef.get() == nullptr || vclmain::isAlive());
+ // We can be one of the intermediate counts, but if we are the last
+ // VclPtr keeping this object alive, then something forgot to call dispose().
+ assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)
+ && "someone forgot to call dispose()");
}
#endif
-#endif
/**
* A construction helper for VclPtr. Since VclPtr types are created
diff --git a/include/vcl/vclreferencebase.hxx b/include/vcl/vclreferencebase.hxx
index f5399c816366..feb1f19523e4 100644
--- a/include/vcl/vclreferencebase.hxx
+++ b/include/vcl/vclreferencebase.hxx
@@ -44,6 +44,13 @@ public:
if (osl_atomic_decrement(&mnRefCnt) == 0)
delete this;
}
+#ifdef DBG_UTIL
+#ifndef WNT
+ int getRefCount() const { return mnRefCnt; }
+#endif
+#endif
+
+
private:
VclReferenceBase(const VclReferenceBase&) = delete;
VclReferenceBase& operator=(const VclReferenceBase&) = delete;