[Libreoffice-commits] core.git: Branch 'libreoffice-5-0-4' - sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Thu Dec 10 18:04:21 PST 2015


 sw/source/core/access/accpara.cxx      |    2 ++
 sw/source/core/attr/calbck.cxx         |    8 ++++++++
 sw/source/core/unocore/unodraw.cxx     |    3 +++
 sw/source/core/unocore/unoflatpara.cxx |    3 +++
 sw/source/core/unocore/unoframe.cxx    |    3 +++
 sw/source/core/unocore/unoport.cxx     |    5 +++++
 sw/source/core/unocore/unosett.cxx     |    1 +
 sw/source/core/unocore/unostyle.cxx    |    2 ++
 sw/source/core/unocore/unotbl.cxx      |   16 ++++++++++++++--
 9 files changed, 41 insertions(+), 2 deletions(-)

New commits:
commit f7be3f85ec624f3cab774f7d3c9a0a9503f6a776
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Nov 9 18:56:17 2015 +0100

    fix a set of race conditions in the writer uno wrappers
    
    - whenever SwClients are added or removed, the SolarMutex should be
      locked
    - locking the mutex there would be a performance killer
    - thus only DBG_TESTSOLARMUTEX() and fixing the fallout on DBG_UTL
      builds
    - also fix SwXFlatParagraphIterator
    - another missing SolarMutex in Writer UNO
    - yet another member of SwXTextPortion needs to be guarded in the dtor
    - another missing SolarMutex in Writer UNO: SwXCell
    
    (cherry-picked from:
     ffdc5db260b7c17c47109f707b3664a3f3caafaa,
     c20930bfec4ce4953ffdaff1971216290fab0e4d,
     e61465d25f5e52bf439db65ed7a641722637034a,
     453cf8a4c44b7935c3029524bfd40fa9c1d87753,
     f019f5d6fe05b15a83a7fea40d9448de2fabb00d)
    
    Change-Id: I1c8413cd0b9baa7f38e452e94f33e29bc4cf6717
    Reviewed-on: https://gerrit.libreoffice.org/19856
    Reviewed-on: https://gerrit.libreoffice.org/20470
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index fab4074..77ec692 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -564,6 +564,8 @@ SwAccessibleParagraph::~SwAccessibleParagraph()
     delete pPortionData;
     delete pHyperTextData;
     delete mpParaChangeTrackInfo; // #i108125#
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
 }
 
 bool SwAccessibleParagraph::HasCursor()
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index d958bd6..e1fb6ea 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -22,12 +22,15 @@
 #include <hints.hxx>
 #include <swcache.hxx>
 #include <swfntcch.hxx>
+#include <tools/debug.hxx>
 
 
 TYPEINIT0( SwClient );
 
 SwClient::~SwClient()
 {
+    if(GetRegisteredIn())
+        DBG_TESTSOLARMUTEX();
     OSL_ENSURE( !pRegisteredIn || pRegisteredIn->HasWriterListeners(), "SwModify still known, but Client already disconnected!" );
     if( pRegisteredIn && pRegisteredIn->HasWriterListeners() )
         pRegisteredIn->Remove( this );
@@ -35,6 +38,7 @@ SwClient::~SwClient()
 
 void SwClient::CheckRegistration( const SfxPoolItem* pOld, const SfxPoolItem* )
 {
+    DBG_TESTSOLARMUTEX();
     // this method only handles notification about dying SwModify objects
     if( (!pOld || pOld->Which() != RES_OBJECTDYING) )
         return;
@@ -58,6 +62,7 @@ void SwClient::CheckRegistration( const SfxPoolItem* pOld, const SfxPoolItem* )
 
 SwModify::~SwModify()
 {
+    DBG_TESTSOLARMUTEX();
     OSL_ENSURE( !IsModifyLocked(), "Modify destroyed but locked." );
 
     if ( IsInCache() )
@@ -94,6 +99,7 @@ SwModify::~SwModify()
 
 void SwModify::NotifyClients( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
 {
+    DBG_TESTSOLARMUTEX();
     if ( IsInCache() || IsInSwFntCache() )
     {
         const sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
@@ -144,6 +150,7 @@ bool SwModify::GetInfo( SfxPoolItem& rInfo ) const
 void SwModify::Add( SwClient* pDepend )
 {
     OSL_ENSURE( !bLockClientList, "Client inserted while in Modify" );
+    DBG_TESTSOLARMUTEX();
 
     if(pDepend->pRegisteredIn != this )
     {
@@ -187,6 +194,7 @@ SwClient* SwModify::Remove( SwClient* pDepend )
     if(m_bInDocDTOR)
         return nullptr;
 
+    DBG_TESTSOLARMUTEX();
     assert(pDepend->pRegisteredIn == this);
 
     // SwClient is my listener
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 7b04865..4001ad9 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1007,12 +1007,15 @@ void SwXShape::AddExistingShapeToFormat( SdrObject& _rObj )
 
 SwXShape::~SwXShape()
 {
+    SolarMutexGuard aGuard;
     if (xShapeAgg.is())
     {
         uno::Reference< uno::XInterface >  xRef;
         xShapeAgg->setDelegator(xRef);
     }
     delete pImpl;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
 }
 
 uno::Any SwXShape::queryInterface( const uno::Type& aType ) throw( uno::RuntimeException, std::exception )
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index 8bda7b7..47b8ce2 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -361,6 +361,9 @@ SwXFlatParagraphIterator::SwXFlatParagraphIterator( SwDoc& rDoc, sal_Int32 nType
 
 SwXFlatParagraphIterator::~SwXFlatParagraphIterator()
 {
+    SolarMutexGuard aGuard;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
 }
 
 void SwXFlatParagraphIterator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 54a5b6b..dd9f789 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1260,8 +1260,11 @@ SwXFrame::SwXFrame(SwFrameFormat& rFrameFormat, FlyCntType eSet, const :: SfxIte
 
 SwXFrame::~SwXFrame()
 {
+    SolarMutexGuard aGuard;
     delete m_pCopySource;
     delete pProps;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
 }
 
 template<class Interface, class NameLookupIsHard>
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 54db643..d4a4f92 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -143,6 +143,11 @@ SwXTextPortion::~SwXTextPortion()
     SolarMutexGuard aGuard;
     SwUnoCrsr* pUnoCrsr = GetCursor();
     delete pUnoCrsr;
+    if(m_FrameDepend.GetRegisteredIn())
+    {
+        auto pFrameDepend(const_cast<SwDepend*>(&m_FrameDepend));
+        pFrameDepend->GetRegisteredIn()->Remove(pFrameDepend);
+    }
 }
 
 uno::Reference< text::XText >  SwXTextPortion::getText()
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 87d0cb5..3e4b38b 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -2099,6 +2099,7 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A
     throw(UnknownPropertyException, PropertyVetoException,
         IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
 {
+    SolarMutexGuard aGuard;
     SwNumRule* pDocRule = 0;
     SwNumRule* pCreatedRule = 0;
     if(!pNumRule)
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 57688c4..b662b66e 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1314,6 +1314,8 @@ SwXStyle::~SwXStyle()
     if(pBasePool)
         EndListening(*pBasePool);
     delete pPropImpl;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove( this );
 }
 
 void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 3437d84..a8f9c1a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -774,6 +774,9 @@ SwXCell::SwXCell(SwFrameFormat* pTableFormat, const SwStartNode& rStartNode) :
 
 SwXCell::~SwXCell()
 {
+    SolarMutexGuard aGuard;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
 }
 
 namespace
@@ -1217,7 +1220,11 @@ SwXTextTableRow::SwXTextTableRow(SwFrameFormat* pFormat, SwTableLine* pLn) :
 { }
 
 SwXTextTableRow::~SwXTextTableRow()
-{ }
+{
+    SolarMutexGuard aGuard;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
+}
 
 uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo() throw( uno::RuntimeException, std::exception )
 {
@@ -1969,7 +1976,12 @@ SwXTextTable::SwXTextTable(SwFrameFormat& rFrameFormat)
 { }
 
 SwXTextTable::~SwXTextTable()
-    { delete pTableProps; }
+{
+    SolarMutexGuard aGuard;
+    delete pTableProps;
+    if(GetRegisteredIn())
+        GetRegisteredIn()->Remove(this);
+}
 
 uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat)
 {


More information about the Libreoffice-commits mailing list