From b9f5607ba8e228d69dba89584ea75136b439b547 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 11 Sep 2016 20:50:21 +0100 Subject: coverity#1371151 rearrange code to avoid assignment Change-Id: Iccba596ce958bcdd62aae572f3189592f96cad25 --- basctl/source/basicide/basobj3.cxx | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'basctl') diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index ad9626e5b3fe..d406120b1d39 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -100,24 +100,18 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ) aOUSource += aSubStr; // update module in library - ScriptDocument aDocument( ScriptDocument::NoDocument ); StarBASIC* pBasic = dynamic_cast(pModule->GetParent()); - DBG_ASSERT(pBasic, "basctl::CreateMacro: No Basic found!"); - if ( pBasic ) + BasicManager* pBasMgr = pBasic ? FindBasicManager(pBasic) : nullptr; + SAL_WARN_IF(!pBasMgr, "basctl.basicide", "No BasicManager found!"); + ScriptDocument aDocument = pBasMgr + ? ScriptDocument::getDocumentForBasicManager(pBasMgr) + : ScriptDocument(ScriptDocument::NoDocument); + + if (aDocument.isValid()) { - BasicManager* pBasMgr = FindBasicManager( pBasic ); - DBG_ASSERT(pBasMgr, "basctl::CreateMacro: No BasicManager found!"); - if ( pBasMgr ) - { - aDocument = ScriptDocument::getDocumentForBasicManager( pBasMgr ); - OSL_ENSURE( aDocument.isValid(), "basctl::CreateMacro: no document for the given BasicManager!" ); - if ( aDocument.isValid() ) - { - OUString aLibName = pBasic->GetName(); - OUString aModName = pModule->GetName(); - OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) ); - } - } + OUString aLibName = pBasic->GetName(); + OUString aModName = pModule->GetName(); + OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) ); } SbMethod* pMethod = pModule->FindMethod( aMacroName, SbxClassType::Method ); @@ -127,8 +121,8 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName ) pDispatcher->Execute( SID_BASICIDE_UPDATEALLMODULESOURCES ); } - if ( aDocument.isAlive() ) - MarkDocumentModified( aDocument ); + if (aDocument.isAlive()) + MarkDocumentModified(aDocument); return pMethod; } -- cgit