[Libreoffice-commits] core.git: 5 commits - sw/source vcl/source
Caolán McNamara
caolanm at redhat.com
Wed Dec 20 15:08:29 UTC 2017
sw/source/core/frmedt/feshview.cxx | 53 ++++++++++++++++--------------------
vcl/source/window/builder.cxx | 2 -
vcl/source/window/menubarwindow.cxx | 3 +-
3 files changed, 28 insertions(+), 30 deletions(-)
New commits:
commit 8af88c48060d2b07255793c9be65f4d085b7b48b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 20 15:05:16 2017 +0000
coverity#1426738 Dereference null return value
Change-Id: I85957928c2f7fa742d379f289192c05e3f4177a8
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 6a8877263b43..f7f933f28a95 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -313,7 +313,7 @@ void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
sal_uInt16 nId = pMenu->GetItemId(i);
MenuItemData* pParentItemData = pMenu->GetItemList()->GetData(nId);
-
+ assert(pParentItemData);
mpParentPopup->InsertItem(nId, pParentItemData->aText, pParentItemData->nBits, pParentItemData->sIdent);
mpParentPopup->SetHelpId(nId, pParentItemData->aHelpId);
mpParentPopup->SetHelpText(nId, pParentItemData->aHelpText);
@@ -370,6 +370,7 @@ void MenuBarWindow::KillActivePopup()
{
sal_uInt16 nId = mpParentPopup->GetItemId(i);
MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
+ assert(pParentItemData);
pParentItemData->pSubMenu = nullptr;
}
}
commit 110544a8039398c66582ba592310e1a58c076970
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 20 15:01:58 2017 +0000
reversed assert
Change-Id: I018417df11a41ebb1c453a51a70368b0eae8f6d4
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 536f07cd1b6a..d0410235ad67 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1644,7 +1644,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
#else
bool ok = pModule->loadRelative(&thisModule, sModule);
#endif
- assert(ok || "bad module name in .ui"); (void)ok;
+ assert(ok && "bad module name in .ui"); (void)ok;
aI = m_aModuleMap.insert(std::make_pair(sModule, std::unique_ptr<osl::Module>(pModule))).first;
}
customMakeWidget pFunction = reinterpret_cast<customMakeWidget>(aI->second->getFunctionSymbol(sFunction));
commit 6069c7590abf8150595cc748a7dfcbb535b13d72
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 20 14:59:42 2017 +0000
coverity#1426742 IsTextBox will be false here unless pVirtO is non-null
Change-Id: I794243a47b1693b8b4454da02efea934535cec48
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 255f7c35a2db..bfd7a0a1bf8b 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1533,7 +1533,7 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
// Ignore TextBoxes of draw shapes here, so that
// SwFEShell::SelectObj() won't jump back on this list, meaning
// we never jump to the next draw shape.
- (pObj && pObj->IsTextBox()) ||
+ (pVirtO && pVirtO->IsTextBox()) ||
( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
( pFilter && !pFilter->includeObject( *pObj ) ) )
commit 2795b4187939a25db54cd871a124b5527ac2ce92
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 20 14:55:29 2017 +0000
replace pVirtO null check with just pVirtO
Change-Id: Ie9ef7736bec84085cdfab41b13059b9cec821ff2
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 34d60c9fdd40..255f7c35a2db 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1528,9 +1528,8 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
{
SdrObject* pObj = aObjIter.Next();
SwVirtFlyDrawObj *pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
- bool bFlyFrame = pVirtO != nullptr;
- if( ( bNoFly && bFlyFrame ) ||
- ( bNoDraw && !bFlyFrame ) ||
+ if( ( bNoFly && pVirtO ) ||
+ ( bNoDraw && !pVirtO ) ||
// Ignore TextBoxes of draw shapes here, so that
// SwFEShell::SelectObj() won't jump back on this list, meaning
// we never jump to the next draw shape.
@@ -1539,7 +1538,7 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
( pFilter && !pFilter->includeObject( *pObj ) ) )
continue;
- if( bFlyFrame )
+ if (pVirtO)
{
SwFlyFrame *pFly = pVirtO->GetFlyFrame();
if( GotoObjFlags::FlyAny != ( GotoObjFlags::FlyAny & eType ) )
@@ -1582,10 +1581,9 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
{
SdrObject* pTmpObj = aTmpIter.Next();
pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pTmpObj);
- bFlyFrame = pVirtO != nullptr;
- if( ( bNoFly && bFlyFrame ) || ( bNoDraw && !bFlyFrame ) )
+ if( ( bNoFly && pVirtO ) || ( bNoDraw && !pVirtO ) )
continue;
- if( bFlyFrame )
+ if (pVirtO)
{
aCurPos = pVirtO->GetFlyFrame()->getFrameArea().Pos();
}
@@ -1646,8 +1644,7 @@ bool SwFEShell::GotoObj( bool bNext, GotoObjFlags eType )
return false;
const SwVirtFlyDrawObj *pVirtO = dynamic_cast<const SwVirtFlyDrawObj*>(pBest);
- bool bFlyFrame = pVirtO != nullptr;
- if( bFlyFrame )
+ if (pVirtO)
{
const SwRect& rFrame = pVirtO->GetFlyFrame()->getFrameArea();
SelectObj( rFrame.Pos(), 0, const_cast<SdrObject*>(pBest) );
commit 8f7d004432a7647c40cc09283e400dbfc1bb73ea
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 20 14:52:04 2017 +0000
dynamic_cast followed by static_cast
Change-Id: Ia2fed1d1ff97108ee3bbe11b5c08901099ee33e6
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 616c00e64c83..34d60c9fdd40 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -144,8 +144,8 @@ SwFlyFrame *GetFlyFromMarked( const SdrMarkList *pLst, SwViewShell *pSh )
if ( pLst && pLst->GetMarkCount() == 1 )
{
SdrObject *pO = pLst->GetMark( 0 )->GetMarkedSdrObj();
- if ( pO && dynamic_cast<const SwVirtFlyDrawObj*>( pO) != nullptr )
- return static_cast<SwVirtFlyDrawObj*>(pO)->GetFlyFrame();
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pO))
+ return pVirtO->GetFlyFrame();
}
return nullptr;
}
@@ -346,9 +346,9 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
SwFrame* pOld;
SwFlyFrame* pFly = nullptr;
SdrObject *pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
- if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
{
- pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
+ pFly = pVirtO->GetFlyFrame();
pOld = pFly->AnchorFrame();
}
else
@@ -825,9 +825,9 @@ static void lcl_NotifyNeighbours( const SdrMarkList *pLst )
sal_Int16 aHori = text::HoriOrientation::NONE;
SwRect aRect;
SdrObject *pO = pLst->GetMark( j )->GetMarkedSdrObj();
- if ( dynamic_cast<const SwVirtFlyDrawObj*>( pO) != nullptr )
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pO))
{
- SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pO)->GetFlyFrame();
+ SwFlyFrame *pFly = pVirtO->GetFlyFrame();
const SwFormatHoriOrient &rHori = pFly->GetFormat()->GetHoriOrient();
aHori = rHori.GetHoriOrient();
@@ -1115,9 +1115,9 @@ void SwFEShell::ChangeOpaque( SdrLayerID nLayerId )
{
pObj->SetLayer( nLayerId );
InvalidateWindows( SwRect( pObj->GetCurrentBoundRect() ) );
- if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
{
- SwFormat *pFormat = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame()->GetFormat();
+ SwFormat *pFormat = pVirtO->GetFlyFrame()->GetFormat();
SvxOpaqueItem aOpa( pFormat->GetOpaque() );
aOpa.SetValue( nLayerId == rIDDMA.GetHellId() );
pFormat->SetFormatAttr( aOpa );
@@ -1527,7 +1527,8 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
while ( aObjIter.IsMore() )
{
SdrObject* pObj = aObjIter.Next();
- bool bFlyFrame = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr;
+ SwVirtFlyDrawObj *pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
+ bool bFlyFrame = pVirtO != nullptr;
if( ( bNoFly && bFlyFrame ) ||
( bNoDraw && !bFlyFrame ) ||
// Ignore TextBoxes of draw shapes here, so that
@@ -1540,8 +1541,7 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
continue;
if( bFlyFrame )
{
- SwVirtFlyDrawObj *pO = static_cast<SwVirtFlyDrawObj*>(pObj);
- SwFlyFrame *pFly = pO->GetFlyFrame();
+ SwFlyFrame *pFly = pVirtO->GetFlyFrame();
if( GotoObjFlags::FlyAny != ( GotoObjFlags::FlyAny & eType ) )
{
switch ( eType )
@@ -1581,13 +1581,13 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
while ( aTmpIter.IsMore() )
{
SdrObject* pTmpObj = aTmpIter.Next();
- bFlyFrame = dynamic_cast<const SwVirtFlyDrawObj*>( pTmpObj) != nullptr;
+ pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pTmpObj);
+ bFlyFrame = pVirtO != nullptr;
if( ( bNoFly && bFlyFrame ) || ( bNoDraw && !bFlyFrame ) )
continue;
if( bFlyFrame )
{
- SwVirtFlyDrawObj *pO = static_cast<SwVirtFlyDrawObj*>(pTmpObj);
- aCurPos = pO->GetFlyFrame()->getFrameArea().Pos();
+ aCurPos = pVirtO->GetFlyFrame()->getFrameArea().Pos();
}
else
aCurPos = pTmpObj->GetCurrentBoundRect().TopLeft();
@@ -1645,11 +1645,11 @@ bool SwFEShell::GotoObj( bool bNext, GotoObjFlags eType )
if ( !pBest )
return false;
- bool bFlyFrame = dynamic_cast<const SwVirtFlyDrawObj*>( pBest) != nullptr;
+ const SwVirtFlyDrawObj *pVirtO = dynamic_cast<const SwVirtFlyDrawObj*>(pBest);
+ bool bFlyFrame = pVirtO != nullptr;
if( bFlyFrame )
{
- const SwVirtFlyDrawObj *pO = static_cast<const SwVirtFlyDrawObj*>(pBest);
- const SwRect& rFrame = pO->GetFlyFrame()->getFrameArea();
+ const SwRect& rFrame = pVirtO->GetFlyFrame()->getFrameArea();
SelectObj( rFrame.Pos(), 0, const_cast<SdrObject*>(pBest) );
if( !ActionPend() )
MakeVisible( rFrame );
@@ -2567,9 +2567,9 @@ FlyProtectFlags SwFEShell::IsSelObjProtected( FlyProtectFlags eType ) const
nChk |= ( pObj->IsMoveProtect() ? FlyProtectFlags::Pos : FlyProtectFlags::NONE ) |
( pObj->IsResizeProtect()? FlyProtectFlags::Size : FlyProtectFlags::NONE );
- if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
{
- SwFlyFrame *pFly = static_cast<SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
+ SwFlyFrame *pFly = pVirtO->GetFlyFrame();
if ( (FlyProtectFlags::Content & eType) && pFly->GetFormat()->GetProtect().IsContentProtected() )
nChk |= FlyProtectFlags::Content;
@@ -2601,8 +2601,8 @@ FlyProtectFlags SwFEShell::IsSelObjProtected( FlyProtectFlags eType ) const
return eType;
}
const SwFrame* pAnch;
- if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr )
- pAnch = static_cast<SwVirtFlyDrawObj*>( pObj )->GetFlyFrame()->GetAnchorFrame();
+ if (SwVirtFlyDrawObj* pVirtO = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
+ pAnch = pVirtO->GetFlyFrame()->GetAnchorFrame();
else
{
SwDrawContact* pTmp = static_cast<SwDrawContact*>(GetUserCall(pObj));
More information about the Libreoffice-commits
mailing list