include/sfx2/infobar.hxx | 6 +++--- include/sfx2/viewfrm.hxx | 2 +- sfx2/source/dialog/infobar.cxx | 13 +++++-------- sfx2/source/view/classificationhelper.cxx | 1 + sfx2/source/view/sfxbasecontroller.cxx | 2 +- sfx2/source/view/viewfrm.cxx | 8 ++++---- 6 files changed, 15 insertions(+), 17 deletions(-)
New commits: commit f82cd9c786933a641ab131758a9fc1bd291824cc Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Jan 3 14:32:24 2017 +0100 Hold SfxInfoBarWindow by VclPtr In SfxInfoBarContainerWindow::removeInfoBar, disposeAndClear is already called on the removed member (once found), so the ScopedVclPtr (also calling disposeAndClear when going out of scope) should not be necessary. Change-Id: Ibf4d19ebd5f1a6217e1d18ef0458c9b865667898 diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx index 2d732bd..8cd6d6c 100644 --- a/include/sfx2/infobar.hxx +++ b/include/sfx2/infobar.hxx @@ -84,14 +84,14 @@ class SfxInfoBarContainerWindow : public vcl::Window virtual ~SfxInfoBarContainerWindow( ) override; virtual void dispose() override; - SfxInfoBarWindow* appendInfoBar(const OUString& sId, + VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor, const basegfx::BColor* pMessageColor, WinBits nMessageStyle); - SfxInfoBarWindow* getInfoBar(const OUString& sId); - void removeInfoBar(SfxInfoBarWindow* pInfoBar); + VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId); + void removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar); virtual void Resize() override; }; diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index d250954..ed8a994 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -170,7 +170,7 @@ public: The buttons will be added from Right to Left at the right of the info bar. The parent, size and position of each button will be changed: only the width will remain unchanged. */ - SfxInfoBarWindow* AppendInfoBar(const OUString& sId, + VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor = nullptr, const basegfx::BColor* pForegroundColor = nullptr, diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index adec4e2..d8fce1f 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -279,7 +279,7 @@ void SfxInfoBarContainerWindow::dispose() Window::dispose(); } -SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, +VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor, @@ -299,25 +299,22 @@ SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, return pInfoBar; } -SfxInfoBarWindow* SfxInfoBarContainerWindow::getInfoBar(const OUString& sId) +VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::getInfoBar(const OUString& sId) { for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it) { if ((*it)->getId() == sId) - return it->get(); + return *it; } return nullptr; } -void SfxInfoBarContainerWindow::removeInfoBar(SfxInfoBarWindow* pInfoBar) +void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar) { - // Store a VclPtr to the pInfoBar while we remove it from m_pInfoBars - ScopedVclPtr<SfxInfoBarWindow> pTmp(pInfoBar); - // Remove for (auto it = m_pInfoBars.begin(); it != m_pInfoBars.end(); ++it) { - if (pInfoBar == it->get()) + if (pInfoBar == *it) { it->disposeAndClear(); m_pInfoBars.erase(it); diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 0bc1a99..614ec98 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/xml/sax/SAXParseException.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <sfx2/infobar.hxx> #include <sfx2/objsh.hxx> #include <o3tl/make_unique.hxx> #include <comphelper/processfactory.hxx> diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index e732d27..4c298be 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -1449,7 +1449,7 @@ void SfxBaseController::ShowInfoBars( ) { // Get the Frame and show the InfoBar if not checked out SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); - SfxInfoBarWindow* pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ) ); + auto pInfoBar = pViewFrame->AppendInfoBar( "checkout", SfxResId( STR_NONCHECKEDOUT_DOCUMENT ) ); if (pInfoBar) { VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow()); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 6e35ade..42a259a 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1201,7 +1201,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { bool bSignPDF = IsSignPDF(m_xObjSh); - SfxInfoBarWindow* pInfoBar = AppendInfoBar("readonly", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT)); + auto pInfoBar = AppendInfoBar("readonly", SfxResId(bSignPDF ? STR_READONLY_PDF : STR_READONLY_DOCUMENT)); if (pInfoBar) { if (bSignPDF) @@ -3063,7 +3063,7 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame ) SfxGetpApp()->SetViewFrame_Impl( pFrame ); } -SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, +VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor, @@ -3080,7 +3080,7 @@ SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, if (pChild) { SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); - SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle); + auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle); ShowChildWindow(nId); return pInfoBar; } @@ -3099,7 +3099,7 @@ void SfxViewFrame::RemoveInfoBar( const OUString& sId ) if (pChild) { SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); - SfxInfoBarWindow* pInfoBar = pInfoBarContainer->getInfoBar(sId); + auto pInfoBar = pInfoBarContainer->getInfoBar(sId); pInfoBarContainer->removeInfoBar(pInfoBar); ShowChildWindow(nId); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits