summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-03 16:19:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-04 14:19:27 +0200
commitb9757f5cfdb62b24e79eeb4c0ef0c8b98056cecf (patch)
tree3eef79200ccbbf509117cc8c44ed4a1b07d645c4
parent270946b220692e466b1eaaed85e4b08ea876fee2 (diff)
loplugin:useuniqueptr in vcl/svdata
Change-Id: I4e5c50e2dde40b4047020fed2733a3e47ed4208e Reviewed-on: https://gerrit.libreoffice.org/59950 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/inc/svdata.hxx36
-rw-r--r--vcl/qt5/Qt5Data.cxx4
-rw-r--r--vcl/qt5/Qt5Instance.cxx5
-rw-r--r--vcl/source/app/svapp.cxx66
-rw-r--r--vcl/source/app/svdata.cxx60
-rw-r--r--vcl/source/app/svmain.cxx71
-rw-r--r--vcl/source/control/button.cxx6
-rw-r--r--vcl/source/gdi/configsettings.cxx4
-rw-r--r--vcl/source/gdi/print.cxx9
-rw-r--r--vcl/source/helper/lazydelete.cxx21
-rw-r--r--vcl/unx/generic/app/salinst.cxx3
-rw-r--r--vcl/unx/gtk/gtkinst.cxx7
-rw-r--r--vcl/unx/kde4/KDESalInstance.cxx3
-rw-r--r--vcl/unx/kde5/KDE5SalInstance.cxx3
14 files changed, 99 insertions, 199 deletions
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 52980ec3260b..679debce188e 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -126,16 +126,16 @@ struct ImplSVAppData
ImeStatusWindowMode_SHOW
};
- AllSettings* mpSettings = nullptr; // Application settings
+ std::unique_ptr<AllSettings> mpSettings; // Application settings
LocaleConfigurationListener* mpCfgListener = nullptr;
- VclEventListeners* mpEventListeners = nullptr; // listeners for vcl events (eg, extended toolkit)
- SVAppKeyListeners* mpKeyListeners = nullptr; // listeners for key events only (eg, extended toolkit)
+ VclEventListeners maEventListeners; // listeners for vcl events (eg, extended toolkit)
+ SVAppKeyListeners maKeyListeners; // listeners for key events only (eg, extended toolkit)
std::vector<ImplPostEventPair> maPostedEventList;
- ImplAccelManager* mpAccelMgr = nullptr; // Accelerator Manager
- OUString* mpAppName = nullptr; // Application name
- OUString* mpAppFileName = nullptr; // Abs. Application FileName
- OUString* mpDisplayName = nullptr; // Application Display Name
- OUString* mpToolkitName = nullptr; // Toolkit Name
+ ImplAccelManager* mpAccelMgr; // Accelerator Manager
+ boost::optional<OUString> mxAppName; // Application name
+ boost::optional<OUString> mxAppFileName; // Abs. Application FileName
+ boost::optional<OUString> mxDisplayName; // Application Display Name
+ boost::optional<OUString> mxToolkitName; // Toolkit Name
Help* mpHelp = nullptr; // Application help
VclPtr<PopupMenu> mpActivePopupMenu; // Actives Popup-Menu (in Execute)
VclPtr<ImplWheelWindow> mpWheelWindow; // WheelWindow
@@ -226,8 +226,8 @@ struct ImplSVCtrlData
{
std::vector<Image> maCheckImgList; // ImageList for CheckBoxes
std::vector<Image> maRadioImgList; // ImageList for RadioButtons
- Image* mpDisclosurePlus = nullptr;
- Image* mpDisclosureMinus = nullptr;
+ std::unique_ptr<Image> mpDisclosurePlus;
+ std::unique_ptr<Image> mpDisclosureMinus;
ImplTBDragMgr* mpTBDragMgr = nullptr; // DragMgr for ToolBox
sal_uInt16 mnCheckStyle = 0; // CheckBox-Style for ImageList-Update
sal_uInt16 mnRadioStyle = 0; // Radio-Style for ImageList-Update
@@ -237,8 +237,8 @@ struct ImplSVCtrlData
Color mnLastRadioFColor; // Last FaceColor for RadioImage
Color mnLastRadioWColor; // Last WindowColor for RadioImage
Color mnLastRadioLColor; // Last LightColor for RadioImage
- FieldUnitStringList* mpFieldUnitStrings = nullptr; // list with field units
- FieldUnitStringList* mpCleanUnitStrings = nullptr; // same list but with some "fluff" like spaces removed
+ FieldUnitStringList maFieldUnitStrings; // list with field units
+ FieldUnitStringList maCleanUnitStrings; // same list but with some "fluff" like spaces removed
};
struct ImplSVHelpData
@@ -341,7 +341,7 @@ struct ImplSVData
VclPtr<WorkWindow> mpDefaultWin; // Default-Window
bool mbDeInit = false; // Is VCL deinitializing
std::unique_ptr<SalI18NImeStatus> mpImeStatus; // interface to ime status window, only used by the X11 backend
- SalSystem* mpSalSystem = nullptr; // SalSystem interface
+ std::unique_ptr<SalSystem> mpSalSystem; // SalSystem interface
bool mbResLocaleSet = false; // SV-Resource-Manager
std::locale maResLocale; // Resource locale
ImplSchedulerContext maSchedCtx; // indepen data for class Scheduler
@@ -353,16 +353,16 @@ struct ImplSVData
ImplSVNWFData maNWFData;
UnoWrapperBase* mpUnoWrapper = nullptr;
VclPtr<vcl::Window> mpIntroWindow; // the splash screen
- DockingManager* mpDockingManager = nullptr;
- BlendFrameCache* mpBlendFrameCache = nullptr;
+ std::unique_ptr<DockingManager> mpDockingManager;
+ std::unique_ptr<BlendFrameCache> mpBlendFrameCache;
oslThreadIdentifier mnMainThreadId = 0;
rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection;
css::uno::Reference< css::lang::XComponent > mxAccessBridge;
- vcl::SettingsConfigItem* mpSettingsConfigItem = nullptr;
- std::vector< vcl::DeleteOnDeinitBase* >* mpDeinitDeleteList = nullptr;
- std::unordered_map< int, OUString >* mpPaperNames = nullptr;
+ std::unique_ptr<vcl::SettingsConfigItem> mpSettingsConfigItem;
+ std::vector< vcl::DeleteOnDeinitBase* > maDeinitDeleteList;
+ std::unordered_map< int, OUString > maPaperNames;
css::uno::Reference<css::i18n::XCharacterClassification> m_xCharClass;
diff --git a/vcl/qt5/Qt5Data.cxx b/vcl/qt5/Qt5Data.cxx
index 284c1614e100..c8f7e4a7570b 100644
--- a/vcl/qt5/Qt5Data.cxx
+++ b/vcl/qt5/Qt5Data.cxx
@@ -316,8 +316,8 @@ bool Qt5Data::noNativeControls()
{
static const bool bNoNative
= ((nullptr != getenv("SAL_VCL_QT5_NO_NATIVE")) && (nullptr != ImplGetSVData())
- && (nullptr != ImplGetSVData()->maAppData.mpToolkitName)
- && ImplGetSVData()->maAppData.mpToolkitName->match("qt5"));
+ && ImplGetSVData()->maAppData.mxToolkitName
+ && ImplGetSVData()->maAppData.mxToolkitName->match("qt5"));
return bNoNative;
}
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index fefc1b1ec1d2..aa04e4a14086 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -49,11 +49,10 @@ Qt5Instance::Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo)
, m_bUseCairo(bUseCairo)
{
ImplSVData* pSVData = ImplGetSVData();
- delete pSVData->maAppData.mpToolkitName;
if (bUseCairo)
- pSVData->maAppData.mpToolkitName = new OUString("qt5+cairo");
+ pSVData->maAppData.mxToolkitName = OUString("qt5+cairo");
else
- pSVData->maAppData.mpToolkitName = new OUString("qt5");
+ pSVData->maAppData.mxToolkitName = OUString("qt5");
m_postUserEventId = QEvent::registerEventType();
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 1bd65ba0570f..565f349072fb 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -236,9 +236,9 @@ OUString Application::GetCommandLineParam( sal_uInt16 nParam )
OUString Application::GetAppFileName()
{
ImplSVData* pSVData = ImplGetSVData();
- SAL_WARN_IF( !pSVData->maAppData.mpAppFileName, "vcl", "AppFileName should be set to something after SVMain!" );
- if ( pSVData->maAppData.mpAppFileName )
- return *pSVData->maAppData.mpAppFileName;
+ SAL_WARN_IF( !pSVData->maAppData.mxAppFileName, "vcl", "AppFileName should be set to something after SVMain!" );
+ if ( pSVData->maAppData.mxAppFileName )
+ return *pSVData->maAppData.mxAppFileName;
/*
* provide a fallback for people without initialized vcl here (like setup
@@ -745,7 +745,7 @@ void InitSettings(ImplSVData* pSVData)
{
assert(!pSVData->maAppData.mpSettings && "initialization should not happen twice!");
- pSVData->maAppData.mpSettings = new AllSettings();
+ pSVData->maAppData.mpSettings.reset(new AllSettings());
if (!utl::ConfigManager::IsFuzzing())
{
pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener;
@@ -779,49 +779,38 @@ void Application::ImplCallEventListenersApplicationDataChanged( void* pData )
ImplSVData* pSVData = ImplGetSVData();
VclWindowEvent aEvent( nullptr, VclEventId::ApplicationDataChanged, pData );
- if ( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->Call( aEvent );
+ pSVData->maAppData.maEventListeners.Call( aEvent );
}
void Application::ImplCallEventListeners( VclSimpleEvent& rEvent )
{
ImplSVData* pSVData = ImplGetSVData();
-
- if ( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->Call( rEvent );
+ pSVData->maAppData.maEventListeners.Call( rEvent );
}
void Application::AddEventListener( const Link<VclSimpleEvent&,void>& rEventListener )
{
ImplSVData* pSVData = ImplGetSVData();
- if( !pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners = new VclEventListeners;
- pSVData->maAppData.mpEventListeners->addListener( rEventListener );
+ pSVData->maAppData.maEventListeners.addListener( rEventListener );
}
void Application::RemoveEventListener( const Link<VclSimpleEvent&,void>& rEventListener )
{
ImplSVData* pSVData = ImplGetSVData();
- if( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->removeListener( rEventListener );
+ pSVData->maAppData.maEventListeners.removeListener( rEventListener );
}
void Application::AddKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener )
{
ImplSVData* pSVData = ImplGetSVData();
- if( !pSVData->maAppData.mpKeyListeners )
- pSVData->maAppData.mpKeyListeners = new SVAppKeyListeners;
- pSVData->maAppData.mpKeyListeners->push_back( rKeyListener );
+ pSVData->maAppData.maKeyListeners.push_back( rKeyListener );
}
void Application::RemoveKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener )
{
ImplSVData* pSVData = ImplGetSVData();
- if( pSVData->maAppData.mpKeyListeners )
- {
- auto pVec = pSVData->maAppData.mpKeyListeners;
- pVec->erase( std::remove(pVec->begin(), pVec->end(), rKeyListener ), pVec->end() );
- }
+ auto & rVec = pSVData->maAppData.maKeyListeners;
+ rVec.erase( std::remove(rVec.begin(), rVec.end(), rKeyListener ), rVec.end() );
}
bool Application::HandleKey( VclEventId nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent )
@@ -831,15 +820,12 @@ bool Application::HandleKey( VclEventId nEvent, vcl::Window *pWin, KeyEvent* pKe
ImplSVData* pSVData = ImplGetSVData();
- if ( !pSVData->maAppData.mpKeyListeners )
- return false;
-
- if ( pSVData->maAppData.mpKeyListeners->empty() )
+ if ( pSVData->maAppData.maKeyListeners.empty() )
return false;
bool bProcessed = false;
// Copy the list, because this can be destroyed when calling a Link...
- std::vector<Link<VclWindowEvent&,bool>> aCopy( *pSVData->maAppData.mpKeyListeners );
+ std::vector<Link<VclWindowEvent&,bool>> aCopy( pSVData->maAppData.maKeyListeners );
for ( Link<VclWindowEvent&,bool>& rLink : aCopy )
{
if( rLink.Call( aEvent ) )
@@ -1109,19 +1095,14 @@ vcl::Window* Application::GetActiveTopWindow()
void Application::SetAppName( const OUString& rUniqueName )
{
ImplSVData* pSVData = ImplGetSVData();
-
- // create if does not exist
- if ( !pSVData->maAppData.mpAppName )
- pSVData->maAppData.mpAppName = new OUString( rUniqueName );
- else
- *(pSVData->maAppData.mpAppName) = rUniqueName;
+ pSVData->maAppData.mxAppName = rUniqueName;
}
OUString Application::GetAppName()
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maAppData.mpAppName )
- return *(pSVData->maAppData.mpAppName);
+ if ( pSVData->maAppData.mxAppName )
+ return *(pSVData->maAppData.mxAppName);
else
return OUString();
}
@@ -1167,19 +1148,14 @@ OUString Application::GetHWOSConfInfo()
void Application::SetDisplayName( const OUString& rName )
{
ImplSVData* pSVData = ImplGetSVData();
-
- // create if does not exist
- if ( !pSVData->maAppData.mpDisplayName )
- pSVData->maAppData.mpDisplayName = new OUString( rName );
- else
- *(pSVData->maAppData.mpDisplayName) = rName;
+ pSVData->maAppData.mxDisplayName = rName;
}
OUString Application::GetDisplayName()
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maAppData.mpDisplayName )
- return *(pSVData->maAppData.mpDisplayName);
+ if ( pSVData->maAppData.mxDisplayName )
+ return *(pSVData->maAppData.mxDisplayName);
else if ( pSVData->maWinData.mpAppWin )
return pSVData->maWinData.mpAppWin->GetText();
else
@@ -1327,8 +1303,8 @@ Help* Application::GetHelp()
OUString Application::GetToolkitName()
{
ImplSVData* pSVData = ImplGetSVData();
- if ( pSVData->maAppData.mpToolkitName )
- return *(pSVData->maAppData.mpToolkitName);
+ if ( pSVData->maAppData.mxToolkitName )
+ return *(pSVData->maAppData.mxToolkitName);
else
return OUString();
}
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 414182375ce4..ce3ed1393729 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -79,8 +79,8 @@ SalSystem* ImplGetSalSystem()
{
ImplSVData* pSVData = ImplGetSVData();
if( ! pSVData->mpSalSystem )
- pSVData->mpSalSystem = pSVData->mpDefInst->CreateSalSystem();
- return pSVData->mpSalSystem;
+ pSVData->mpSalSystem.reset( pSVData->mpDefInst->CreateSalSystem() );
+ return pSVData->mpSalSystem.get();
}
void ImplDeInitSVData()
@@ -88,33 +88,13 @@ void ImplDeInitSVData()
ImplSVData* pSVData = ImplGetSVData();
// delete global instance data
- if( pSVData->mpSettingsConfigItem )
- {
- delete pSVData->mpSettingsConfigItem;
- pSVData->mpSettingsConfigItem = nullptr;
- }
+ pSVData->mpSettingsConfigItem.reset();
- if( pSVData->mpDockingManager )
- {
- delete pSVData->mpDockingManager;
- pSVData->mpDockingManager = nullptr;
- }
+ pSVData->mpDockingManager.reset();
- if( pSVData->maCtrlData.mpFieldUnitStrings )
- {
- delete pSVData->maCtrlData.mpFieldUnitStrings;
- pSVData->maCtrlData.mpFieldUnitStrings = nullptr;
- }
- if( pSVData->maCtrlData.mpCleanUnitStrings )
- {
- delete pSVData->maCtrlData.mpCleanUnitStrings;
- pSVData->maCtrlData.mpCleanUnitStrings = nullptr;
- }
- if( pSVData->mpPaperNames )
- {
- delete pSVData->mpPaperNames;
- pSVData->mpPaperNames = nullptr;
- }
+ pSVData->maCtrlData.maFieldUnitStrings.clear();
+ pSVData->maCtrlData.maCleanUnitStrings.clear();
+ pSVData->maPaperNames.clear();
}
/// Returns either the application window, or the default GL context window
@@ -182,60 +162,58 @@ OUString VclResId(const char* pId)
FieldUnitStringList* ImplGetFieldUnits()
{
ImplSVData* pSVData = ImplGetSVData();
- if( ! pSVData->maCtrlData.mpFieldUnitStrings )
+ if( pSVData->maCtrlData.maFieldUnitStrings.empty() )
{
sal_uInt32 nUnits = SAL_N_ELEMENTS(SV_FUNIT_STRINGS);
- pSVData->maCtrlData.mpFieldUnitStrings = new FieldUnitStringList;
- pSVData->maCtrlData.mpFieldUnitStrings->reserve( nUnits );
+ pSVData->maCtrlData.maFieldUnitStrings.reserve( nUnits );
for (sal_uInt32 i = 0; i < nUnits; i++)
{
std::pair<OUString, FieldUnit> aElement(VclResId(SV_FUNIT_STRINGS[i].first), SV_FUNIT_STRINGS[i].second);
- pSVData->maCtrlData.mpFieldUnitStrings->push_back( aElement );
+ pSVData->maCtrlData.maFieldUnitStrings.push_back( aElement );
}
}
- return pSVData->maCtrlData.mpFieldUnitStrings;
+ return &pSVData->maCtrlData.maFieldUnitStrings;
}
FieldUnitStringList* ImplGetCleanedFieldUnits()
{
ImplSVData* pSVData = ImplGetSVData();
- if( ! pSVData->maCtrlData.mpCleanUnitStrings )
+ if( pSVData->maCtrlData.maCleanUnitStrings.empty() )
{
FieldUnitStringList* pUnits = ImplGetFieldUnits();
if( pUnits )
{
size_t nUnits = pUnits->size();
- pSVData->maCtrlData.mpCleanUnitStrings = new FieldUnitStringList;
- pSVData->maCtrlData.mpCleanUnitStrings->reserve( nUnits );
+ pSVData->maCtrlData.maCleanUnitStrings.reserve( nUnits );
for( size_t i = 0; i < nUnits; ++i )
{
OUString aUnit( (*pUnits)[i].first );
aUnit = aUnit.replaceAll(" ", "");
aUnit = aUnit.toAsciiLowerCase();
std::pair< OUString, FieldUnit > aElement( aUnit, (*pUnits)[i].second );
- pSVData->maCtrlData.mpCleanUnitStrings->push_back( aElement );
+ pSVData->maCtrlData.maCleanUnitStrings.push_back( aElement );
}
}
}
- return pSVData->maCtrlData.mpCleanUnitStrings;
+ return &pSVData->maCtrlData.maCleanUnitStrings;
}
DockingManager* ImplGetDockingManager()
{
ImplSVData* pSVData = ImplGetSVData();
if ( !pSVData->mpDockingManager )
- pSVData->mpDockingManager = new DockingManager();
+ pSVData->mpDockingManager.reset(new DockingManager());
- return pSVData->mpDockingManager;
+ return pSVData->mpDockingManager.get();
}
BlendFrameCache* ImplGetBlendFrameCache()
{
ImplSVData* pSVData = ImplGetSVData();
if ( !pSVData->mpBlendFrameCache)
- pSVData->mpBlendFrameCache= new BlendFrameCache();
+ pSVData->mpBlendFrameCache.reset( new BlendFrameCache() );
- return pSVData->mpBlendFrameCache;
+ return pSVData->mpBlendFrameCache.get();
}
#ifdef _WIN32
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 9e4e3ca1a04a..beed24273e0d 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -359,12 +359,12 @@ bool InitVCL()
// convert path to native file format
OUString aNativeFileName;
osl::FileBase::getSystemPathFromFileURL( aExeFileName, aNativeFileName );
- pSVData->maAppData.mpAppFileName = new OUString( aNativeFileName );
+ pSVData->maAppData.mxAppFileName = aNativeFileName;
// Initialize global data
pSVData->maGDIData.mxScreenFontList.reset(new PhysicalFontCollection);
pSVData->maGDIData.mxScreenFontCache.reset(new ImplFontCache);
- pSVData->maGDIData.mpGrfConverter = new GraphicConverter;
+ pSVData->maGDIData.mpGrfConverter = new GraphicConverter;
g_bIsLeanException = getenv("LO_LEAN_EXCEPTION") != nullptr;
// Set exception handler
@@ -473,29 +473,21 @@ void DeInitVCL()
pExceptionHandler = nullptr;
// free global data
- delete pSVData->maGDIData.mpGrfConverter;
-
- if( pSVData->mpSettingsConfigItem )
+ if (pSVData->maGDIData.mpGrfConverter)
{
- delete pSVData->mpSettingsConfigItem;
- pSVData->mpSettingsConfigItem = nullptr;
+ delete pSVData->maGDIData.mpGrfConverter;
+ pSVData->maGDIData.mpGrfConverter = nullptr;
}
+ pSVData->mpSettingsConfigItem.reset();
+
Scheduler::ImplDeInitScheduler();
pSVData->maWinData.maMsgBoxImgList.clear();
pSVData->maCtrlData.maCheckImgList.clear();
pSVData->maCtrlData.maRadioImgList.clear();
- if ( pSVData->maCtrlData.mpDisclosurePlus )
- {
- delete pSVData->maCtrlData.mpDisclosurePlus;
- pSVData->maCtrlData.mpDisclosurePlus = nullptr;
- }
- if ( pSVData->maCtrlData.mpDisclosureMinus )
- {
- delete pSVData->maCtrlData.mpDisclosureMinus;
- pSVData->maCtrlData.mpDisclosureMinus = nullptr;
- }
+ pSVData->maCtrlData.mpDisclosurePlus.reset();
+ pSVData->maCtrlData.mpDisclosureMinus.reset();
pSVData->mpDefaultWin.disposeAndClear();
#ifndef NDEBUG
@@ -540,56 +532,21 @@ void DeInitVCL()
delete pSVData->maAppData.mpCfgListener;
}
- delete pSVData->maAppData.mpSettings;
- pSVData->maAppData.mpSettings = nullptr;
+ pSVData->maAppData.mpSettings.reset();
}
- if ( pSVData->maAppData.mpAccelMgr )
+ if (pSVData->maAppData.mpAccelMgr)
{
delete pSVData->maAppData.mpAccelMgr;
pSVData->maAppData.mpAccelMgr = nullptr;
}
- if ( pSVData->maAppData.mpAppFileName )
- {
- delete pSVData->maAppData.mpAppFileName;
- pSVData->maAppData.mpAppFileName = nullptr;
- }
- if ( pSVData->maAppData.mpAppName )
- {
- delete pSVData->maAppData.mpAppName;
- pSVData->maAppData.mpAppName = nullptr;
- }
- if ( pSVData->maAppData.mpDisplayName )
- {
- delete pSVData->maAppData.mpDisplayName;
- pSVData->maAppData.mpDisplayName = nullptr;
- }
- if ( pSVData->maAppData.mpToolkitName )
- {
- delete pSVData->maAppData.mpToolkitName;
- pSVData->maAppData.mpToolkitName = nullptr;
- }
- if ( pSVData->maAppData.mpEventListeners )
- {
- delete pSVData->maAppData.mpEventListeners;
- pSVData->maAppData.mpEventListeners = nullptr;
- }
- if ( pSVData->maAppData.mpKeyListeners )
- {
- delete pSVData->maAppData.mpKeyListeners;
- pSVData->maAppData.mpKeyListeners = nullptr;
- }
- if (pSVData->mpBlendFrameCache)
- {
- delete pSVData->mpBlendFrameCache;
- pSVData->mpBlendFrameCache = nullptr;
- }
+ pSVData->maAppData.maKeyListeners.clear();
+ pSVData->mpBlendFrameCache.reset();
ImplDeletePrnQueueList();
// destroy all Sal interfaces before destroying the instance
// and thereby unloading the plugin
- delete pSVData->mpSalSystem;
- pSVData->mpSalSystem = nullptr;
+ pSVData->mpSalSystem.reset();
assert( !pSVData->maSchedCtx.mpSalTimer );
delete pSVData->maSchedCtx.mpSalTimer;
pSVData->maSchedCtx.mpSalTimer = nullptr;
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index bfbbd4ab191d..39acdd39e955 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3812,12 +3812,12 @@ void DisclosureButton::ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext)
ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
if (!rCtrlData.mpDisclosurePlus)
- rCtrlData.mpDisclosurePlus = new Image(BitmapEx(SV_DISCLOSURE_PLUS));
+ rCtrlData.mpDisclosurePlus.reset(new Image(BitmapEx(SV_DISCLOSURE_PLUS)));
if (!rCtrlData.mpDisclosureMinus)
- rCtrlData.mpDisclosureMinus = new Image(BitmapEx(SV_DISCLOSURE_MINUS));
+ rCtrlData.mpDisclosureMinus.reset(new Image(BitmapEx(SV_DISCLOSURE_MINUS)));
Image* pImg = nullptr;
- pImg = IsChecked() ? rCtrlData.mpDisclosureMinus : rCtrlData.mpDisclosurePlus;
+ pImg = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get();
SAL_WARN_IF(!pImg, "vcl", "no disclosure image");
if (!pImg)
diff --git a/vcl/source/gdi/configsettings.cxx b/vcl/source/gdi/configsettings.cxx
index d4419f52b460..ce8816f6da8b 100644
--- a/vcl/source/gdi/configsettings.cxx
+++ b/vcl/source/gdi/configsettings.cxx
@@ -40,8 +40,8 @@ SettingsConfigItem* SettingsConfigItem::get()
{
ImplSVData* pSVData = ImplGetSVData();
if( ! pSVData->mpSettingsConfigItem )
- pSVData->mpSettingsConfigItem = new SettingsConfigItem();
- return pSVData->mpSettingsConfigItem;
+ pSVData->mpSettingsConfigItem.reset( new SettingsConfigItem() );
+ return pSVData->mpSettingsConfigItem.get();
}
SettingsConfigItem::SettingsConfigItem()
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 2574e37f6736..c767a0a65c02 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1436,9 +1436,8 @@ int Printer::GetPaperInfoCount() const
OUString Printer::GetPaperName( Paper ePaper )
{
ImplSVData* pSVData = ImplGetSVData();
- if( ! pSVData->mpPaperNames )
+ if( pSVData->maPaperNames.empty() )
{
- pSVData->mpPaperNames = new std::unordered_map< int, OUString >;
static const int PaperIndex[] =
{
PAPER_A0, PAPER_A1, PAPER_A2, PAPER_A3, PAPER_A4, PAPER_A5,
@@ -1452,11 +1451,11 @@ OUString Printer::GetPaperName( Paper ePaper )
};
assert(SAL_N_ELEMENTS(PaperIndex) == SAL_N_ELEMENTS(RID_STR_PAPERNAMES) && "localized paper name count wrong");
for (size_t i = 0; i < SAL_N_ELEMENTS(PaperIndex); ++i)
- (*pSVData->mpPaperNames)[PaperIndex[i]] = VclResId(RID_STR_PAPERNAMES[i]);
+ pSVData->maPaperNames[PaperIndex[i]] = VclResId(RID_STR_PAPERNAMES[i]);
}
- std::unordered_map<int,OUString>::const_iterator it = pSVData->mpPaperNames->find( static_cast<int>(ePaper) );
- return (it != pSVData->mpPaperNames->end()) ? it->second : OUString();
+ std::unordered_map<int,OUString>::const_iterator it = pSVData->maPaperNames.find( static_cast<int>(ePaper) );
+ return (it != pSVData->maPaperNames.end()) ? it->second : OUString();
}
OUString Printer::GetPaperName() const
diff --git a/vcl/source/helper/lazydelete.cxx b/vcl/source/helper/lazydelete.cxx
index 6ce0c21effd5..05e1eef56d92 100644
--- a/vcl/source/helper/lazydelete.cxx
+++ b/vcl/source/helper/lazydelete.cxx
@@ -63,9 +63,10 @@ bool LazyDeletor::is_less( vcl::Window const * left, vcl::Window const * right )
DeleteOnDeinitBase::~DeleteOnDeinitBase()
{
ImplSVData* pSVData = ImplGetSVData();
- if( pSVData && pSVData->mpDeinitDeleteList != nullptr )
- pSVData->mpDeinitDeleteList->erase(std::remove(pSVData->mpDeinitDeleteList->begin(), pSVData->mpDeinitDeleteList->end(), this),
- pSVData->mpDeinitDeleteList->end());
+ if( !pSVData )
+ return;
+ auto & rList = pSVData->maDeinitDeleteList;
+ rList.erase(std::remove(rList.begin(), rList.end(), this), rList.end());
}
void DeleteOnDeinitBase::addDeinitContainer( DeleteOnDeinitBase* i_pContainer )
@@ -76,23 +77,17 @@ void DeleteOnDeinitBase::addDeinitContainer( DeleteOnDeinitBase* i_pContainer )
if( pSVData->mbDeInit )
return;
- if( pSVData->mpDeinitDeleteList == nullptr )
- pSVData->mpDeinitDeleteList = new std::vector< DeleteOnDeinitBase* >;
- pSVData->mpDeinitDeleteList->push_back( i_pContainer );
+ pSVData->maDeinitDeleteList.push_back( i_pContainer );
}
void DeleteOnDeinitBase::ImplDeleteOnDeInit()
{
ImplSVData* pSVData = ImplGetSVData();
- if( pSVData->mpDeinitDeleteList )
+ for (auto const& deinitDelete : pSVData->maDeinitDeleteList)
{
- for (auto const& deinitDelete : *(pSVData->mpDeinitDeleteList))
- {
- deinitDelete->doCleanup();
- }
- delete pSVData->mpDeinitDeleteList;
- pSVData->mpDeinitDeleteList = nullptr;
+ deinitDelete->doCleanup();
}
+ pSVData->maDeinitDeleteList.clear();
}
} // namespace vcl
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index ec3dd01d7891..96ab14e5596b 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -71,8 +71,7 @@ X11SalInstance::X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex)
, mpXLib(nullptr)
{
ImplSVData* pSVData = ImplGetSVData();
- delete pSVData->maAppData.mpToolkitName;
- pSVData->maAppData.mpToolkitName = new OUString("x11");
+ pSVData->maAppData.mxToolkitName = OUString("x11");
}
X11SalInstance::~X11SalInstance()
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 134ae11ed0b6..cc93d73b4080 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -178,13 +178,12 @@ void GtkInstance::EnsureInit()
InitAtkBridge();
ImplSVData* pSVData = ImplGetSVData();
- delete pSVData->maAppData.mpToolkitName;
#ifdef GTK_TOOLKIT_NAME
- pSVData->maAppData.mpToolkitName = new OUString(GTK_TOOLKIT_NAME);
+ pSVData->maAppData.mxToolkitName = OUString(GTK_TOOLKIT_NAME);
#elif GTK_CHECK_VERSION(3,0,0)
- pSVData->maAppData.mpToolkitName = new OUString("gtk3");
+ pSVData->maAppData.mxToolkitName = OUString("gtk3");
#else
- pSVData->maAppData.mpToolkitName = new OUString("gtk2");
+ pSVData->maAppData.mxToolkitName = OUString("gtk2");
#endif
bNeedsInit = false;
diff --git a/vcl/unx/kde4/KDESalInstance.cxx b/vcl/unx/kde4/KDESalInstance.cxx
index 4af2c7888cb6..c11d62689b52 100644
--- a/vcl/unx/kde4/KDESalInstance.cxx
+++ b/vcl/unx/kde4/KDESalInstance.cxx
@@ -35,8 +35,7 @@ KDESalInstance::KDESalInstance(std::unique_ptr<SalYieldMutex> pMutex)
: X11SalInstance(std::move(pMutex))
{
ImplSVData* pSVData = ImplGetSVData();
- delete pSVData->maAppData.mpToolkitName;
- pSVData->maAppData.mpToolkitName = new OUString("kde4");
+ pSVData->maAppData.mxToolkitName = OUString("kde4");
}
SalFrame* KDESalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nState )
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index ec117b2104fc..d3362545f5b6 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -43,8 +43,7 @@ KDE5SalInstance::KDE5SalInstance(std::unique_ptr<SalYieldMutex> pMutex)
: Qt5Instance(std::move(pMutex), true)
{
ImplSVData* pSVData = ImplGetSVData();
- delete pSVData->maAppData.mpToolkitName;
- pSVData->maAppData.mpToolkitName = new OUString("kde5");
+ pSVData->maAppData.mxToolkitName = OUString("kde5");
KDE5SalData::initNWF();
}