[Libreoffice-commits] core.git: 2 commits - writerfilter/source
Michael Meeks
michael.meeks at collabora.com
Wed Jul 16 08:01:10 PDT 2014
writerfilter/source/ooxml/OOXMLFactory.cxx | 2 +-
writerfilter/source/ooxml/OOXMLFactory.hxx | 15 +++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 9aeadc76a4f2c878f83f07959d9d1694ff13fddf
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Wed Jul 16 15:56:49 2014 +0100
Cleanup intrusive_ptr usage temporarily.
When we update boost, we should use boost::intrusive_ref_counter
in non-threadsafe mode instead here.
Change-Id: Id63610bf14d7fcb7f681e009a5ac6e4f8e077a81
diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx
index c45b4f5..eb5e4b4 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -102,8 +102,8 @@ OOXMLFactory::Pointer_t OOXMLFactory::m_Instance;
OOXMLFactory::OOXMLFactory()
{
// multi-thread-safe mutex for all platforms
-
osl::MutexGuard aGuard(OOXMLFactory_Mutex::get());
+ mnRefCnt = 0;
}
OOXMLFactory::~OOXMLFactory()
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx
index 405e47a..0150acb 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -148,16 +148,8 @@ public:
void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken);
virtual ~OOXMLFactory();
- inline void IncRef() const{osl_atomic_increment(&mnRefCnt);}
- inline void DecRef() const
- {
- if (!osl_atomic_decrement(&mnRefCnt))
- const_cast<OOXMLFactory*>(this)->Delete();
- }
- inline void Delete() {delete this;}
- inline oslInterlockedCount GetRef() const { return mnRefCnt; }
-protected:
- mutable oslInterlockedCount mnRefCnt; // reference count
+public:
+ sal_uInt32 mnRefCnt;
private:
static Pointer_t m_Instance;
@@ -170,13 +162,14 @@ private:
Token_t Element);
};
- inline void intrusive_ptr_add_ref(const OOXMLFactory* p)
+ inline void intrusive_ptr_add_ref(OOXMLFactory* p)
{
- p->IncRef();
+ p->mnRefCnt++;
}
- inline void intrusive_ptr_release(const OOXMLFactory* p)
+ inline void intrusive_ptr_release(OOXMLFactory* p)
{
- p->DecRef();
+ if (!(--p->mnRefCnt))
+ delete p;
}
}
}
commit c04a0895df86f40faef1bc093f7010f374df9d0b
Author: Fahad Al-Saidi <fahad.alsaidi at gmail.com>
Date: Wed Jul 16 11:30:43 2014 +0400
fdo#80907 Implemented OOXMLFactory using boost::intrusive_ptr.
Change-Id: I350bca3544680ab8227d3bb1c093cba981cba5fc
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx
index ac021ad..405e47a 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -28,6 +28,7 @@
#include <ooxml/OOXMLFastTokens.hxx>
#include "OOXMLFastContextHandler.hxx"
+#include <boost/intrusive_ptr.hpp>
namespace writerfilter {
namespace ooxml {
@@ -127,7 +128,7 @@ protected:
class OOXMLFactory
{
public:
- typedef boost::shared_ptr<OOXMLFactory> Pointer_t;
+ typedef boost::intrusive_ptr<OOXMLFactory>Pointer_t;
static Pointer_t getInstance();
@@ -147,7 +148,16 @@ public:
void endAction(OOXMLFastContextHandler * pHandler, Token_t nToken);
virtual ~OOXMLFactory();
-
+ inline void IncRef() const{osl_atomic_increment(&mnRefCnt);}
+ inline void DecRef() const
+ {
+ if (!osl_atomic_decrement(&mnRefCnt))
+ const_cast<OOXMLFactory*>(this)->Delete();
+ }
+ inline void Delete() {delete this;}
+ inline oslInterlockedCount GetRef() const { return mnRefCnt; }
+protected:
+ mutable oslInterlockedCount mnRefCnt; // reference count
private:
static Pointer_t m_Instance;
@@ -160,6 +170,14 @@ private:
Token_t Element);
};
+ inline void intrusive_ptr_add_ref(const OOXMLFactory* p)
+ {
+ p->IncRef();
+ }
+ inline void intrusive_ptr_release(const OOXMLFactory* p)
+ {
+ p->DecRef();
+ }
}
}
More information about the Libreoffice-commits
mailing list