diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-08-26 20:44:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-08-27 09:41:41 +0200 |
commit | 740194221e096ce437e8ac64fdc49e3957b6918e (patch) | |
tree | 92b6fc44b9478e8a28f8721a8782c24aa52d0b0e /basic/source/classes | |
parent | 0fb841d90a8b6cb3e45436489763a875d5bf4c59 (diff) |
use a shared_ptr for SbiBreakpoints pBreaks as well
Change-Id: I3dec5ffe5fdf937d761c902970a94b73878a2cd9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172441
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'basic/source/classes')
-rw-r--r-- | basic/source/classes/sb.cxx | 5 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 20 |
2 files changed, 7 insertions, 18 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 9720031dfc1a..1f1714fe7377 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -612,7 +612,6 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) aOUSource = pClassModule->aOUSource; aComment = pClassModule->aComment; pImage = pClassModule->pImage; - // see comment in destructor about this pBreaks = pClassModule->pBreaks; SetClassName( pClassModule->GetName() ); @@ -755,10 +754,6 @@ SbClassModuleObject::~SbClassModuleObject() if( const DocBasicItem* pDocBasicItem = lclFindDocBasicItem( pDocBasic ) ) if( !pDocBasicItem->isDocClosed() ) triggerTerminateEvent(); - - // prevent the base class destructor from deleting this because - // we do not actually own it - pBreaks = nullptr; } void SbClassModuleObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 95d751bb0202..81faaaa05f1f 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -417,8 +417,8 @@ static bool getDefaultVBAMode( StarBASIC* pb ) // could be found from other module. SbModule::SbModule( const OUString& rName, bool bVBASupport ) - : SbxObject( u"StarBASICModule"_ustr ), - pBreaks(nullptr), mbVBASupport(bVBASupport), mbCompat(bVBASupport), bIsProxyModule(false) + : SbxObject( u"StarBASICModule"_ustr ) + , mbVBASupport(bVBASupport), mbCompat(bVBASupport), bIsProxyModule(false) { SetName( rName ); SetFlag( SbxFlagBits::ExtSearch | SbxFlagBits::GlobalSearch ); @@ -436,7 +436,7 @@ SbModule::~SbModule() { SAL_INFO("basic","Module named " << GetName() << " is destructing"); pImage.reset(); - delete pBreaks; + pBreaks.reset(); pClassData.reset(); mxWrapper = nullptr; } @@ -1525,7 +1525,7 @@ bool SbModule::SetBP( sal_uInt16 nLine ) if( !IsBreakable( nLine ) ) return false; if( !pBreaks ) - pBreaks = new SbiBreakpoints; + pBreaks.reset(new SbiBreakpoints); auto it = std::find_if(pBreaks->begin(), pBreaks->end(), [&nLine](const sal_uInt16 b) { return b <= nLine; }); if (it != pBreaks->end() && *it == nLine) @@ -1548,22 +1548,16 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) [&nLine](const sal_uInt16 b) { return b <= nLine; }); bRes = (it != pBreaks->end()) && (*it == nLine); if (bRes) - { pBreaks->erase(it); - } - if( pBreaks->empty() ) - { - delete pBreaks; - pBreaks = nullptr; - } + if (pBreaks->empty()) + pBreaks.reset(); } return bRes; } void SbModule::ClearAllBP() { - delete pBreaks; - pBreaks = nullptr; + pBreaks.reset(); } void |