From 9f7ac479ff134d0f9ce65f6f8681e5e7664f357b Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Tue, 14 Jan 2020 12:19:15 +0300 Subject: tdf#129360: don't try to use uninitialized objects And also don't forget to re-initialize member list of watch item. Another old bug masked by hacks removed in commit 62f3f3d92aa204eaaa063b30d7ade44df501b997. E.g., previously in code Type t1 var1 var2 End Type Type t2 var1 var2 var3 End Type Sub test Dim v1 As t1, v2 As t2, v v = v1 v = v2 End Sub breaking on line 'v = v1', expanding v in Watch, and stepping to next line, didn't update the children count. After the change, this surfaced, and now fixed. Change-Id: Ia47f5363a2fc62042701ff14d084870d1cced392 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86792 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- basctl/source/basicide/baside2b.cxx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'basctl/source') diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index c6c954d36013..7449ba41f197 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -2492,21 +2492,16 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) { if ( pItem->mpObject.is() && !pItem->maMemberList.empty() ) { - bool bObjChanged = false; // Check if member list has changed + createAllObjectProperties(pObj); SbxArray* pProps = pObj->GetProperties(); const sal_uInt32 nPropCount = getCorrectedPropCount(pProps); - for( sal_uInt32 i = 0 ; i < nPropCount ; i++ ) + // Check if member list has changed + bCollapse = pItem->maMemberList.size() != nPropCount; + for( sal_uInt32 i = 0 ; !bCollapse && i < nPropCount ; i++ ) { SbxVariable* pVar_ = pProps->Get32( i ); if( pItem->maMemberList[i] != pVar_->GetName() ) - { - bObjChanged = true; - break; - } - } - if( bObjChanged ) - { - bCollapse = true; + bCollapse = true; } } @@ -2520,8 +2515,6 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) if( pItem->mpObject.is() ) { bCollapse = true; - pItem->clearWatchItem(); - implEnableChildren( pEntry, false ); } } @@ -2531,8 +2524,6 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) if( pItem->mpObject.is() ) { bCollapse = true; - pItem->clearWatchItem(); - implEnableChildren( pEntry, false ); } @@ -2565,6 +2556,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) if( bCollapse ) { implCollapseModifiedObjectEntry( pEntry, this ); + pItem->clearWatchItem(); } } @@ -2573,8 +2565,10 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) if( pItem->mpObject.is() || pItem->mpArray.is() ) { implCollapseModifiedObjectEntry( pEntry, this ); - pItem->mpObject = nullptr; + pItem->mpObject.clear(); + pItem->mpArray.clear(); } + pItem->clearWatchItem(); } SvHeaderTabListBox::SetEntryText( aWatchStr, pEntry, ITEM_ID_VALUE-1 ); -- cgit