diff options
author | Noel Grandin <noel@peralex.com> | 2015-12-04 11:52:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-04 11:07:34 +0000 |
commit | 9e2973dbb90b5d9ce004cbf333f5000e4d50dc18 (patch) | |
tree | 039d1dba4fcd8fd0db8eb8e94be113201da128e6 /sw/source/core/unocore | |
parent | b1ff7054a0d7c12e0961c7a78bb2626b33c7f0d1 (diff) |
fix SwClient crash in SwXNumberingRules/SwXTableRows/SwXTableColumns
was generated a crash when running 'make check' on my Linux box.
These classes need to hold the SolarMutex when destructing their
SwClient base class.
Change-Id: I448ea00978d003aa37d8663d37b4edf9e54a6a56
Reviewed-on: https://gerrit.libreoffice.org/20391
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 36 |
2 files changed, 57 insertions, 13 deletions
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index e34c0d259635..b3a55713c4e4 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1048,7 +1048,20 @@ void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString& /* OSL_FAIL("not implemented"); } -const char aInvalidStyle[] = "__XXX___invalid"; +static const char aInvalidStyle[] = "__XXX___invalid"; + + +class SwXNumberingRules::Impl : public SwClient +{ +private: + SwXNumberingRules& m_rParent; +public: + Impl(SwXNumberingRules& rParent) : m_rParent(rParent) {} +protected: + //SwClient + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; +}; + bool SwXNumberingRules::isInvalidStyle(const OUString &rName) { @@ -1094,6 +1107,7 @@ Sequence< OUString > SwXNumberingRules::getSupportedServiceNames() throw( Runtim } SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) : + m_pImpl(new SwXNumberingRules::Impl(*this)), pDoc(doc), pDocShell(nullptr), pNumRule(new SwNumRule(rRule)), @@ -1113,7 +1127,7 @@ SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) : } } if(pDoc) - pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); + pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); for(sal_uInt16 i = 0; i < MAXLEVEL; ++i) { m_sNewCharStyleNames[i] = aInvalidStyle; @@ -1122,23 +1136,25 @@ SwXNumberingRules::SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc) : } SwXNumberingRules::SwXNumberingRules(SwDocShell& rDocSh) : + m_pImpl(new SwXNumberingRules::Impl(*this)), pDoc(nullptr), pDocShell(&rDocSh), pNumRule(nullptr), m_pPropertySet(GetNumberingRulesSet()), bOwnNumRuleCreated(false) { - pDocShell->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); + pDocShell->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); } SwXNumberingRules::SwXNumberingRules(SwDoc& rDoc) : + m_pImpl(new SwXNumberingRules::Impl(*this)), pDoc(&rDoc), pDocShell(nullptr), pNumRule(nullptr), m_pPropertySet(GetNumberingRulesSet()), bOwnNumRuleCreated(false) { - rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); + rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(&*m_pImpl); m_sCreatedNumRuleName = rDoc.GetUniqueNumRuleName(); #if OSL_DEBUG_LEVEL > 1 const sal_uInt16 nIndex = @@ -2249,15 +2265,15 @@ void SwXNumberingRules::setName(const OUString& /*rName*/) throw( RuntimeExcepti throw aExcept; } -void SwXNumberingRules::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXNumberingRules::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); if(!GetRegisteredIn()) { - if(bOwnNumRuleCreated) - delete pNumRule; - pNumRule = nullptr; - pDoc = nullptr; + if(m_rParent.bOwnNumRuleCreated) + delete m_rParent.pNumRule; + m_rParent.pNumRule = nullptr; + m_rParent.pDoc = nullptr; } } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 3d8c53dadba4..d8cf5c6ac459 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3756,6 +3756,15 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) } } +class SwXTableRows::Impl : public SwClient +{ +public: + Impl(SwFrameFormat& rFrameFormat) : SwClient(&rFrameFormat) {} +protected: + //SwClient + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; +}; + // SwXTableRows OUString SwXTableRows::getImplementationName() throw( uno::RuntimeException, std::exception ) @@ -3769,12 +3778,17 @@ uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames() throw( uno::R SwXTableRows::SwXTableRows(SwFrameFormat& rFrameFormat) : - SwClient(&rFrameFormat) + m_pImpl(new SwXTableRows::Impl(rFrameFormat)) { } SwXTableRows::~SwXTableRows() { } +SwFrameFormat* SwXTableRows::GetFrameFormat() +{ + return static_cast<SwFrameFormat*>(m_pImpl->GetRegisteredIn()); +} + sal_Int32 SwXTableRows::getCount() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; @@ -3904,11 +3918,20 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) } } -void SwXTableRows::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXTableRows::Impl::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); } // SwXTableColumns +class SwXTableColumns::Impl : public SwClient +{ +public: + Impl(SwFrameFormat& rFrameFormat) : SwClient(&rFrameFormat) {} +protected: + //SwClient + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; +}; + OUString SwXTableColumns::getImplementationName() throw( uno::RuntimeException, std::exception ) { return OUString("SwXTableColumns"); } @@ -3920,12 +3943,17 @@ uno::Sequence< OUString > SwXTableColumns::getSupportedServiceNames() throw( uno SwXTableColumns::SwXTableColumns(SwFrameFormat& rFrameFormat) : - SwClient(&rFrameFormat) + m_pImpl(new SwXTableColumns::Impl(rFrameFormat)) { } SwXTableColumns::~SwXTableColumns() { } +SwFrameFormat* SwXTableColumns::GetFrameFormat() const +{ + return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(m_pImpl->GetRegisteredIn())); +} + sal_Int32 SwXTableColumns::getCount() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; @@ -4044,7 +4072,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) } } -void SwXTableColumns::Modify(const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXTableColumns::Impl::Modify(const SfxPoolItem* pOld, const SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |