tdf#57308 - Basic IDE: Watching of a variable does not work

Watching a variable which returns a value from a function always shows
"out of scope" in the watch window of the Basic IDE. In order to resolve
this issue, the name of the variable being watched will be searched also
in the current method instance.

Change-Id: I5ff6ce22067e11d74275eeb82da814da1eebe3db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124239
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
Andreas Heinisch 2021-10-26 21:03:41 +02:00
parent 12c6b1ef6a
commit 7d27e4b025
2 changed files with 17 additions and 4 deletions

View file

@ -2373,7 +2373,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
eEnableChildren = TRISTATE_TRUE;
}
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
if (SbxVariable* pVar = dynamic_cast<SbxVariable*>(pSBX))
{
// extra treatment of arrays
SbxDataType eType = pVar->GetType();
@ -2486,7 +2486,11 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
{
aWatchStr += aStrStr;
}
// tdf#57308 - avoid a second call to retrieve the data
const SbxFlagBits nFlags = pVar->GetFlags();
pVar->SetFlag(SbxFlagBits::NoBroadcast);
aWatchStr += pVar->GetOUString();
pVar->SetFlags(nFlags);
if( bString )
{
aWatchStr += aStrStr;

View file

@ -3754,10 +3754,19 @@ SbxBase* SbiRuntime::FindElementExtern( const OUString& rName )
}
if ( !pElem && pMeth )
{
// for statics, set the method's name in front
OUString aMethName = pMeth->GetName() + ":" + rName;
pElem = pMod->Find(aMethName, SbxClassType::DontCare);
const OUString aMethName = pMeth->GetName();
// tdf#57308 - check if the name is the current method instance
if (pMeth->GetName() == rName)
{
pElem = pMeth;
}
else
{
// for statics, set the method's name in front
pElem = pMod->Find(aMethName + ":" + rName, SbxClassType::DontCare);
}
}
// search in parameter list
if( !pElem && pMeth )