sw/inc/unosett.hxx | 13 +++++++------ sw/inc/unotbl.hxx | 24 ++++++++++-------------- sw/source/core/unocore/unosett.cxx | 34 +++++++++++++++++++++++++--------- sw/source/core/unocore/unotbl.cxx | 36 ++++++++++++++++++++++++++++++++---- 4 files changed, 74 insertions(+), 33 deletions(-)
New commits: commit e8e01f16ece5f3c5dd1f75b5a1aee26a839ddb22 Author: Noel Grandin <n...@peralex.com> Date: Fri Dec 4 11:52:53 2015 +0200 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. Reviewed-on: https://gerrit.libreoffice.org/20391 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> (cherry picked from commit 9e2973dbb90b5d9ce004cbf333f5000e4d50dc18) Signed-off-by: Michael Stahl <mst...@redhat.com> Change-Id: I448ea00978d003aa37d8663d37b4edf9e54a6a56 diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx index d19f5f1..7e10aca 100644 --- a/sw/inc/unosett.hxx +++ b/sw/inc/unosett.hxx @@ -32,6 +32,7 @@ #include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase5.hxx> #include <svl/itemprop.hxx> +#include <unobaseclass.hxx> class SwDoc; class SwFormatCol; @@ -136,9 +137,12 @@ class SwXNumberingRules : public cppu::WeakAggImplHelper5 css::beans::XPropertySet, css::container::XNamed, css::lang::XServiceInfo ->, - public SwClient +> { +private: + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + OUString m_sNewCharStyleNames[MAXLEVEL]; OUString m_sNewBulletFontNames[MAXLEVEL]; OUString m_sCreatedNumRuleName; //connects to a numbering in SwDoc @@ -146,13 +150,10 @@ class SwXNumberingRules : public cppu::WeakAggImplHelper5 SwDocShell* pDocShell; // Only if used as chapter numbering. SwNumRule* pNumRule; const SfxItemPropertySet* m_pPropertySet; - bool bOwnNumRuleCreated; + bool bOwnNumRuleCreated; protected: virtual ~SwXNumberingRules(); - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; - public: SwXNumberingRules(SwDocShell& rDocSh); // chapter numbering SwXNumberingRules(const SwNumRule& rRule, SwDoc* doc = nullptr); // NumRule for paragraphs, numbering styles diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index eb1ad4a..46e3221 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -546,11 +546,12 @@ class SwXTableRows final : public cppu::WeakImplHelper < css::table::XTableRows, css::lang::XServiceInfo ->, - public SwClient - +> { - SwFrameFormat* GetFrameFormat() { return static_cast<SwFrameFormat*>(GetRegisteredIn()); } +private: + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + SwFrameFormat* GetFrameFormat(); const SwFrameFormat* GetFrameFormat() const { return const_cast<SwXTableRows*>(this)->GetFrameFormat(); } protected: virtual ~SwXTableRows(); @@ -578,20 +579,18 @@ public: virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override; - - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; }; class SwXTableColumns : public cppu::WeakImplHelper < css::table::XTableColumns, css::lang::XServiceInfo ->, - public SwClient - +> { - SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); } +private: + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + SwFrameFormat* GetFrameFormat() const; protected: virtual ~SwXTableColumns(); public: @@ -618,9 +617,6 @@ public: virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override; - - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; }; int sw_CompareCellRanges( diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index e34c0d2..b3a5571 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 dbe0462..c373efd 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3811,6 +3811,15 @@ void SwXCellRange::Impl::Modify( } } +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 ) @@ -3824,12 +3833,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; @@ -3959,11 +3973,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"); } @@ -3975,12 +3998,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; @@ -4099,7 +4127,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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits