basctl/source/basicide/basidesh.cxx | 4 ++-- basctl/source/basicide/basobj2.cxx | 2 +- basctl/source/basicide/basobj3.cxx | 1 + basctl/source/dlged/dlged.cxx | 20 ++++++-------------- basctl/source/dlged/propbrw.cxx | 10 +++++++++- fpicker/source/office/fileview.cxx | 2 +- fpicker/source/office/iodlgimp.cxx | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-)
New commits: commit d7790878e315f795f5d9965dd9997ba3a5004c60 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed May 1 12:47:26 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed May 1 15:29:44 2024 +0200 WaE: C6011 Dereferencing NULL pointer warnings Change-Id: I9870360076260e71c0e02375558606cbdb68fc08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166960 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index bdf68e11a7dc..9f08b9b00a8b 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -421,7 +421,7 @@ void Shell::StoreAllWindowData( bool bPersistent ) for (auto const& window : aWindowTable) { BaseWindow* pWin = window.second; - DBG_ASSERT( pWin, "PrepareClose: NULL-Pointer in Table?" ); + assert(pWin && "PrepareClose: NULL-Pointer in Table?"); if ( !pWin->IsSuspended() ) pWin->StoreData(); } @@ -782,7 +782,7 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange { VclPtr<BaseWindow> pWindowTmp( pWindow_ ); - DBG_ASSERT( pWindow_, "Cannot delete NULL-Pointer!" ); + assert(pWindow_ && "Cannot delete NULL-Pointer!"); sal_uInt16 nKey = GetWindowId( pWindow_ ); pTabBar->RemovePage( nKey ); aWindowTable.erase( nKey ); diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 708b1ce035d2..0aa3b8b37bf5 100644 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -391,7 +391,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt SbMethod* pMethod = static_cast<SbMethod*>(pMod->GetMethods()->Get(i)); if( pMethod->IsHidden() ) continue; - SAL_WARN_IF( !pMethod, "basctl.basicide","Method not found! (NULL)" ); + assert(pMethod && "Method not found! (NULL)"); aSeqMethods.getArray()[ iTarget++ ] = pMethod->GetName(); } } diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 1e51cbbb2ed8..f8af9e037b60 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -116,6 +116,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ) if (aDocument.isValid()) { + assert(pBasic && "isValid cannot be false with !pBasic"); const OUString& aLibName = pBasic->GetName(); const OUString& aModName = pModule->GetName(); OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) ); diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 40a7b5c75850..b8f3901eb34b 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -526,28 +526,20 @@ void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle SdrPageView* pPgView = pDlgEdView->GetSdrPageView(); const vcl::Region aPaintRectRegion(aPaintRect); - // #i74769# - SdrPaintWindow* pTargetPaintWindow = nullptr; - // mark repaint start if (pPgView) { - pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(&rRenderContext, aPaintRectRegion); - OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)"); - } + // #i74769# + SdrPaintWindow* pTargetPaintWindow(pPgView->GetView().BeginDrawLayers(&rRenderContext, aPaintRectRegion)); + assert(pTargetPaintWindow && "BeginDrawLayers: Got no SdrPaintWindow (!)"); - // draw background self using wallpaper - // #i79128# ...and use correct OutDev for that - if (pTargetPaintWindow) - { + // draw background self using wallpaper + // #i79128# ...and use correct OutDev for that Color maBackColor = rRenderContext.GetSettings().GetStyleSettings().GetLightColor(); OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice(); rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(maBackColor)); - } - // do paint (unbuffered) and mark repaint end - if (pPgView) - { + // do paint (unbuffered) and mark repaint end // paint of control layer is done in EndDrawLayers anyway... pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true); } diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx index bb45d5f13e8d..04fa2b3d3b86 100644 --- a/basctl/source/dlged/propbrw.cxx +++ b/basctl/source/dlged/propbrw.cxx @@ -82,11 +82,18 @@ const tools::Long WIN_BORDER = 2; } // namespace +static Reference<XModel> lclGetModel() +{ + if (SfxViewShell* pCurrent = SfxViewShell::Current()) + return pCurrent->GetCurrentDocument(); + return Reference<XModel>(); +} + PropBrw::PropBrw (DialogWindowLayout& rLayout_): DockingWindow(&rLayout_), m_xContentArea(VclPtr<VclVBox>::Create(this)), m_bInitialStateChange(true), - m_xContextDocument(SfxViewShell::Current() ? SfxViewShell::Current()->GetCurrentDocument() : Reference<XModel>()), + m_xContextDocument(lclGetModel()), pView(nullptr) { Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y); @@ -241,6 +248,7 @@ Sequence< Reference< XInterface > > for( size_t i = 0 ; i < nMarkCount ; ++i ) { SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj(); + assert(pCurrent && "GetMarkedSdrObj will succeed"); std::optional<SdrObjListIter> oGroupIterator; if (pCurrent->IsGroupObject()) diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx index 6a77f9154ac8..9dcb55a8cbfb 100644 --- a/fpicker/source/office/fileview.cxx +++ b/fpicker/source/office/fileview.cxx @@ -1574,7 +1574,7 @@ static const CollatorWrapper* pCollatorWrapper = nullptr; */ static bool CompareSortingData_Impl( std::unique_ptr<SortingData_Impl> const & aOne, std::unique_ptr<SortingData_Impl> const & aTwo ) { - DBG_ASSERT( pCollatorWrapper, "*CompareSortingData_Impl(): Can't work this way!" ); + assert(pCollatorWrapper && "*CompareSortingData_Impl(): Can't work this way!"); sal_Int32 nComp; bool bRet = false; diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx index 1802d9c8d65b..547456c2cf68 100644 --- a/fpicker/source/office/iodlgimp.cxx +++ b/fpicker/source/office/iodlgimp.cxx @@ -148,7 +148,7 @@ namespace { void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl const * pFilter, const OUString& rDisplayName ) { - DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" ); + assert(pFilter && "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!"); DBG_ASSERT( ( rDisplayName == pFilter->GetName() ) || ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ), "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );