diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-11-09 18:56:17 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-12-13 17:33:30 +0100 |
commit | c52f7af0a0c1ecea9c6a2500e0f2b2893347fbd4 (patch) | |
tree | 16425094a34ae15b0855daffe74b262e692a07cd | |
parent | c79153bf4b1369c07dbd303f7ef9fd883a02a8db (diff) |
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/20089
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
(cherry picked from commit 351ac4169244ca2dd89ce449d7c4cfdb02af23f9)
-rw-r--r-- | sw/source/core/access/accpara.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/attr/calbck.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoport.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 16 |
9 files changed, 41 insertions, 2 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index fab40746f65c..77ec69205988 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 d958bd64a4db..e1fb6ea01851 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 7b0486537421..4001ad95825a 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 8bda7b7647a5..47b8ce261bde 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 54a5b6ba963c..dd9f7894531a 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 54db6433298a..d4a4f929a3ce 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 87d0cb52785b..3e4b38ba8516 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 57688c4bbfc0..b662b66e2ac2 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 3437d84e3973..a8f9c1a4be32 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) { |