diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-10 12:53:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-11 06:55:41 +0000 |
commit | 78b4a1fb01af9ad3b3395a22f6e396be914b553e (patch) | |
tree | 846fdaea907a70fdc274a1e76642ed5e06622c0d /sfx2 | |
parent | 071e23fee07b92b8f07800cda3ca7e66afe818ae (diff) |
update vclwidget loplugin to find ref-dropping assigment
Look for places where we are accidentally assigning a returned-by-value
VclPtr<T> to a T*, which generally ends up in a use-after-free.
Change-Id: I4f361eaca88820cdb7aa3b8340212db61580fdd9
Reviewed-on: https://gerrit.libreoffice.org/30749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/appl/sfxhelp.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/backingcomp.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/dockwin.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/mailmodel.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/iframe.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/inet/inettbc.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/notebookbar/SfxNotebookBar.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerFactory.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/sidebar/FocusManager.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/sidebar/UnoDeck.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/classificationcontroller.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/view/frame2.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/ipclient.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 4 |
18 files changed, 24 insertions, 24 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index ba810a1781a9..7345027ab9ec 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -1243,7 +1243,7 @@ namespace try { Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW ); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" ); if ( pWindow ) diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 9735cb280471..c803c15f898d 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -2657,7 +2657,7 @@ void SfxHelpWindow_Impl::MakeLayout() { if ( nHeight > 0 && xWindow.is() ) { - vcl::Window* pScreenWin = VCLUnoHelper::GetWindow(xWindow); + VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow(xWindow); /* #i55528# Hide() / Show() will produce strange effects. @@ -2781,7 +2781,7 @@ void SfxHelpWindow_Impl::SaveConfig() aUserData += ";"; aUserData += OUString::number( nH ); - vcl::Window* pScreenWin = VCLUnoHelper::GetWindow( xWindow ); + VclPtr<vcl::Window> pScreenWin = VCLUnoHelper::GetWindow( xWindow ); aWinPos = pScreenWin->GetWindowExtentsRelative( nullptr ).TopLeft(); aUserData += ";"; aUserData += OUString::number( aWinPos.X() ); diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 9247ac5cf961..2a4c32566c98 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -406,7 +406,7 @@ SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame2 >& rHelpTask , // create all internal windows and sub frames ... Reference< css::awt::XWindow > xParentWindow = xHelpTask->getContainerWindow(); - vcl::Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); VclPtrInstance<SfxHelpWindow_Impl> pHelpWindow( xHelpTask, pParentWindow, WB_DOCKBORDER ); Reference< css::awt::XWindow > xHelpWindow = VCLUnoHelper::GetInterface( pHelpWindow ); diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 43f018de78b5..0e53109a83d3 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -700,7 +700,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno } // create the component window - vcl::Window* pParent = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow); VclPtr<vcl::Window> pWindow = VclPtr<BackingWindow>::Create(pParent); m_xWindow = VCLUnoHelper::GetInterface(pWindow); @@ -772,8 +772,8 @@ void SAL_CALL BackingComp::dispatch( const css::util::URL& aURL, const css::uno: // vnd.org.libreoffice.recentdocs:ClearRecentFileList - clear recent files if ( aURL.Path == "ClearRecentFileList" ) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow(m_xWindow); - BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(m_xWindow); + BackingWindow* pBack = dynamic_cast<BackingWindow*>(pWindow.get()); if( pBack ) { pBack->clearRecentFileList(); diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 76c41d2ac048..a51397d07906 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -197,7 +197,7 @@ SfxDockingWrapper::SfxDockingWrapper( vcl::Window* pParentWnd , { } - vcl::Window* pContentWindow = VCLUnoHelper::GetWindow(xWindow); + VclPtr<vcl::Window> pContentWindow = VCLUnoHelper::GetWindow(xWindow); if ( pContentWindow ) pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL ); pTitleDockWindow->SetWrappedWindow(pContentWindow); diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index e9bc1be90f0e..d7d2b55d3984 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -821,7 +821,7 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css: css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow(); SolarMutexGuard aGuard; - vcl::Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); ScopedVclPtrInstance< MessageDialog > aBox(pParentWindow, "ErrorFindEmailDialog", "sfx/ui/errorfindemaildialog.ui"); aBox->Execute(); diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index ca68c676bcb2..d50427043b47 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -168,7 +168,7 @@ throw( uno::RuntimeException, std::exception ) if ( SvtMiscOptions().IsPluginsEnabled() ) { DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); - vcl::Window* pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() ); pWin->SetSizePixel( pParent->GetOutputSizePixel() ); pWin->SetBackground(); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 4dadf7f2bf25..87179deafe99 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3604,7 +3604,7 @@ void SAL_CALL SfxBaseModel::setVisualAreaSize( sal_Int64 nAspect, const awt::Siz SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst( m_pData->m_pObjectShell.get(), false ); if ( pViewFrm && m_pData->m_pObjectShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && !pViewFrm->GetFrame().IsInPlace() ) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow( pViewFrm->GetFrame().GetFrameInterface()->getContainerWindow() ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( pViewFrm->GetFrame().GetFrameInterface()->getContainerWindow() ); Size aWinSize = pWindow->GetSizePixel(); awt::Size aCurrent = getVisualAreaSize( nAspect ); Size aDiff( aSize.Width-aCurrent.Width, aSize.Height-aCurrent.Height ); diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx index dbd3a513a87b..d13ad0371732 100644 --- a/sfx2/source/inet/inettbc.cxx +++ b/sfx2/source/inet/inettbc.cxx @@ -175,7 +175,7 @@ IMPL_LINK_NOARG(SfxURLToolBoxControl_Impl, OpenHdl, SvtURLBox*, void) Reference< XFrame > xFrame( xDesktop->getActiveFrame(), UNO_QUERY ); if ( xFrame.is() ) { - vcl::Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); if ( pWin ) { pWin->GrabFocus(); diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index ba277c6ed174..c3821b6d6ff9 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -258,7 +258,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, OUString sFile = lcl_getNotebookbarFileName( eApp ); OUString sNewFile = rUIFile + sFile; OUString sCurrentFile; - NotebookBar* pNotebookBar = pSysWindow->GetNotebookBar(); + VclPtr<NotebookBar> pNotebookBar = pSysWindow->GetNotebookBar(); if ( pNotebookBar ) sCurrentFile = OStringToOUString( pNotebookBar->getUIFile(), RTL_TEXTENCODING_ASCII_US ); diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx index 085a8ccfe5f0..45d26eb854a4 100644 --- a/sfx2/source/sidebar/ControllerFactory.cxx +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -106,7 +106,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController( if (rxParentWindow.is()) { Reference<awt::XWindow> xItemWindow (xController->createItemWindow(rxParentWindow)); - vcl::Window* pItemWindow = VCLUnoHelper::GetWindow(xItemWindow); + VclPtr<vcl::Window> pItemWindow = VCLUnoHelper::GetWindow(xItemWindow); if (pItemWindow != nullptr) { WindowType nType = pItemWindow->GetType(); diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx index 1a4350830bb3..2b02b96f6fef 100644 --- a/sfx2/source/sidebar/FocusManager.cxx +++ b/sfx2/source/sidebar/FocusManager.cxx @@ -253,8 +253,8 @@ void FocusManager::FocusPanel ( void FocusManager::FocusPanelContent (const sal_Int32 nPanelIndex) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow(maPanels[nPanelIndex]->GetElementWindow()); - if (pWindow != nullptr) + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(maPanels[nPanelIndex]->GetElementWindow()); + if (pWindow) { mbObservingContentControlFocus = true; pWindow->GrabFocus(); diff --git a/sfx2/source/sidebar/UnoDeck.cxx b/sfx2/source/sidebar/UnoDeck.cxx index 4fc0e158f07f..0c2b2cf1a1d3 100644 --- a/sfx2/source/sidebar/UnoDeck.cxx +++ b/sfx2/source/sidebar/UnoDeck.cxx @@ -47,7 +47,7 @@ OUString SAL_CALL SfxUnoDeck::getTitle() SolarMutexGuard aGuard; SidebarController* pSidebarController = getSidebarController(); - Deck* pDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck; + VclPtr<Deck> pDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck; if (!pDeck) { diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index 6ef356dd63fc..1b069cc736a2 100644 --- a/sfx2/source/view/classificationcontroller.cxx +++ b/sfx2/source/view/classificationcontroller.cxx @@ -153,8 +153,8 @@ void ClassificationCategoriesController::dispose() throw (uno::RuntimeException, uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) { - vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent); - ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent); + ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent.get()); if (pToolbar) { m_pClassification = VclPtr<ClassificationControl>::Create(pToolbar); diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx index 6f8e7d43f577..4a88eeacb616 100644 --- a/sfx2/source/view/frame2.cxx +++ b/sfx2/source/view/frame2.cxx @@ -280,7 +280,7 @@ SfxFrame* SfxFrame::Create( const Reference < XFrame >& i_rFrame ) { // create a new TopFrame to an external XFrame object ( wrap controller ) ENSURE_OR_THROW( i_rFrame.is(), "NULL frame not allowed" ); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( i_rFrame->getContainerWindow() ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( i_rFrame->getContainerWindow() ); ENSURE_OR_THROW( pWindow, "frame without container window not allowed" ); SfxFrame* pFrame = new SfxFrame( *pWindow ); diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 3b080e8b7856..504997fb3459 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -1036,7 +1036,7 @@ void SfxInPlaceClient::DeactivateObject() uno::Reference< frame::XController > xController = xModel->getCurrentController(); if ( xController.is() ) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow( xController->getFrame()->getContainerWindow() ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xController->getFrame()->getContainerWindow() ); bHasFocus = pWindow->HasChildPathFocus( true ); } } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 0f7b11db6be7..9240a3a6f1dc 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1614,7 +1614,7 @@ void SfxViewFrame::MakeActive_Impl( bool bGrabFocus ) xSupp->setActiveFrame( uno::Reference < frame::XFrame >() ); css::uno::Reference< css::awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); - vcl::Window* pWindow = VCLUnoHelper::GetWindow(xContainerWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow); if (pWindow && pWindow->HasChildPathFocus() && bGrabFocus) { SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient(); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index f6f432b87443..135f2ffdbe4b 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -450,8 +450,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) if(xElement.is()) { uno::Reference< awt::XWindow > xWin( xElement->getRealInterface(), uno::UNO_QUERY_THROW ); - vcl::Window* pWin = VCLUnoHelper::GetWindow( xWin ); - ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin ); + VclPtr<vcl::Window> pWin = VCLUnoHelper::GetWindow( xWin ); + ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin.get() ); if( pTextToolbox ) { sal_uInt16 nItemCount = pTextToolbox->GetItemCount(); |