diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-01-03 14:32:24 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-01-03 14:32:24 +0100 |
commit | f82cd9c786933a641ab131758a9fc1bd291824cc (patch) | |
tree | 5d76fed083ddfa5b7657a550846582de4d8b51d2 /sfx2 | |
parent | 36cdf3c35459df63ce137e550a6840a61865c0ca (diff) |
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
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/view/sfxbasecontroller.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 8 |
4 files changed, 11 insertions, 13 deletions
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index adec4e2629d1..d8fce1f9e202 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 0bc1a991ab44..614ec9800a63 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 e732d27eccf4..4c298be7affc 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 6e35adef40c1..42a259abaa95 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); } |