[Libreoffice-commits] core.git: writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Mar 14 07:59:03 UTC 2018


 writerfilter/source/rtftok/rtfsprm.cxx |    8 ++++----
 writerfilter/source/rtftok/rtfsprm.hxx |   15 +++------------
 2 files changed, 7 insertions(+), 16 deletions(-)

New commits:
commit 80f9383f1adf3a42c22765c7c8bee8e705e39d0b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Mar 13 22:12:05 2018 +0100

    boost::intrusive_ptr->tools::SvRef
    
    To avoid semi-manual refcount handling.
    
    Change-Id: I4a0bcd00ef2811a76f85313d2f821daa1731898c
    Reviewed-on: https://gerrit.libreoffice.org/51242
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx
index e021feee623c..271ad821cef3 100644
--- a/writerfilter/source/rtftok/rtfsprm.cxx
+++ b/writerfilter/source/rtftok/rtfsprm.cxx
@@ -273,9 +273,9 @@ bool RTFSprms::equals(RTFValue& rOther)
 
 void RTFSprms::ensureCopyBeforeWrite()
 {
-    if (m_pSprms->m_nRefCount > 1)
+    if (m_pSprms->GetRefCount() > 1)
     {
-        boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl);
+        tools::SvRef<RTFSprmsImpl> pClone(new RTFSprmsImpl);
         for (auto& rSprm : *m_pSprms)
             pClone->push_back(
                 std::make_pair(rSprm.first, RTFValue::Pointer_t(rSprm.second->Clone())));
@@ -294,10 +294,10 @@ RTFSprms::RTFSprms(const RTFSprms& rSprms) { *this = rSprms; }
 
 void RTFSprms::clear()
 {
-    if (m_pSprms->m_nRefCount == 1)
+    if (m_pSprms->GetRefCount() == 1)
         return m_pSprms->clear();
 
-    m_pSprms.reset(new RTFSprmsImpl);
+    m_pSprms = tools::SvRef<RTFSprmsImpl>(new RTFSprmsImpl);
 }
 
 } // namespace rtftok
diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx
index 7839682343b8..bb9228074277 100644
--- a/writerfilter/source/rtftok/rtfsprm.hxx
+++ b/writerfilter/source/rtftok/rtfsprm.hxx
@@ -14,7 +14,7 @@
 #include <utility>
 #include <vector>
 
-#include <boost/intrusive_ptr.hpp>
+#include <tools/ref.hxx>
 #include "rtfvalue.hxx"
 
 namespace writerfilter
@@ -24,19 +24,10 @@ namespace rtftok
 using RTFSprmsImplBase = std::vector<std::pair<Id, RTFValue::Pointer_t>>;
 
 /// The payload of RTFSprms which is only copied on write.
-class RTFSprmsImpl : public RTFSprmsImplBase
+class RTFSprmsImpl : public RTFSprmsImplBase, public SvRefBase
 {
-public:
-    sal_Int32 m_nRefCount = 0;
 };
 
-inline void intrusive_ptr_add_ref(RTFSprmsImpl* p) { ++(p->m_nRefCount); }
-inline void intrusive_ptr_release(RTFSprmsImpl* p)
-{
-    if (!--(p->m_nRefCount))
-        delete p;
-}
-
 enum class RTFOverwrite
 {
     YES, ///< Yes, if an existing key is found, overwrite it.
@@ -75,7 +66,7 @@ public:
 
 private:
     void ensureCopyBeforeWrite();
-    boost::intrusive_ptr<RTFSprmsImpl> m_pSprms;
+    tools::SvRef<RTFSprmsImpl> m_pSprms;
 };
 
 /// RTF keyword with a parameter


More information about the Libreoffice-commits mailing list