previewpane: use RAII for FileExplorerPreviewSettings classes to avoid memory leaks

This commit is contained in:
yuyoyuppe
2020-10-20 15:01:45 +03:00
committed by Andrey Nekrasov
parent 6c62be1818
commit f506980e4d
7 changed files with 43 additions and 54 deletions

View File

@@ -12,24 +12,16 @@ namespace PowerPreviewSettings
extern "C" IMAGE_DOS_HEADER __ImageBase;
// Base Settings Class Implementation
FileExplorerPreviewSettings::FileExplorerPreviewSettings(bool toggleSettingEnabled, const std::wstring& toggleSettingName, const std::wstring& toggleSettingDescription, LPCWSTR clsid, const std::wstring& registryValueData, RegistryWrapperIface* registryWrapper) :
FileExplorerPreviewSettings::FileExplorerPreviewSettings(bool toggleSettingEnabled, const std::wstring& toggleSettingName, const std::wstring& toggleSettingDescription, LPCWSTR clsid, const std::wstring& registryValueData, std::unique_ptr<RegistryWrapperIface> registryWrapper) :
m_toggleSettingEnabled(toggleSettingEnabled),
m_toggleSettingName(toggleSettingName),
m_toggleSettingDescription(toggleSettingDescription),
m_clsid(clsid),
m_registryValueData(registryValueData),
m_registryWrapper(registryWrapper)
m_registryWrapper(std::move(registryWrapper))
{
}
FileExplorerPreviewSettings::~FileExplorerPreviewSettings()
{
if (this->m_registryWrapper != NULL)
{
delete this->m_registryWrapper;
}
}
bool FileExplorerPreviewSettings::GetToggleSettingState() const
{
return this->m_toggleSettingEnabled;