[Libreoffice-commits] core.git: include/vcl

Noel Grandin noel.grandin at collabora.co.uk
Mon May 22 06:40:16 UTC 2017


 include/vcl/vclptr.hxx           |    8 +++++---
 include/vcl/vclreferencebase.hxx |    7 +++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 40a9cb3ba4d63eef736ce449567061a4ffa90714
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon May 15 15:33:25 2017 +0200

    verify that VclPtr properly disposed
    
    Change-Id: Ia76b7ad9e6d7fefaf0088372b5f5fc7dc51c2846
    Reviewed-on: https://gerrit.libreoffice.org/37649
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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;


More information about the Libreoffice-commits mailing list