From ab72cf32182dd0a6df16b0802c64894b12fce33d Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 20 Sep 2022 11:26:51 -0600 Subject: [PATCH] Tweaks --- Library/MeasureNowPlaying.cpp | 4 +++- Library/SkinRegistry.cpp | 2 +- Library/TrayIcon.cpp | 6 +++++- Plugins/PluginFolderInfo/FolderInfoPlugin.cpp | 6 +++--- Plugins/PluginPerfMon/PerfData.cpp | 8 ++++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Library/MeasureNowPlaying.cpp b/Library/MeasureNowPlaying.cpp index 4044f7213..225d93773 100644 --- a/Library/MeasureNowPlaying.cpp +++ b/Library/MeasureNowPlaying.cpp @@ -59,11 +59,13 @@ MeasureNowPlaying::~MeasureNowPlaying() if (--m_Parent->measureCount == 0) { player->RemoveInstance(); - delete m_Parent; auto iter = std::find(g_ParentMeasures.begin(), g_ParentMeasures.end(), m_Parent); g_ParentMeasures.erase(iter); + delete m_Parent; + m_Parent = nullptr; + if (g_ParentMeasures.empty()) { Internet::Finalize(); diff --git a/Library/SkinRegistry.cpp b/Library/SkinRegistry.cpp index 16f9ca3ef..46f1f596f 100644 --- a/Library/SkinRegistry.cpp +++ b/Library/SkinRegistry.cpp @@ -133,7 +133,7 @@ void SkinRegistry::Populate(const std::wstring& path, std::vector& int SkinRegistry::PopulateRecursive(const std::wstring& path, std::vector& favorites, std::wstring base, int index, UINT level) { - WIN32_FIND_DATA fileData = { 0 }; // Data structure describes the file foun; + WIN32_FIND_DATA fileData = { 0 }; // Data structure describes the file found HANDLE hSearch = nullptr; // Search handle returned by FindFirstFile std::list subfolders; diff --git a/Library/TrayIcon.cpp b/Library/TrayIcon.cpp index fcb5b61f6..484db9dae 100644 --- a/Library/TrayIcon.cpp +++ b/Library/TrayIcon.cpp @@ -73,7 +73,11 @@ TrayIcon::~TrayIcon() } m_Icons.clear(); - if (m_Window) DestroyWindow(m_Window); + if (m_Window) + { + DestroyWindow(m_Window); + m_Window = nullptr; + } } void TrayIcon::Initialize() diff --git a/Plugins/PluginFolderInfo/FolderInfoPlugin.cpp b/Plugins/PluginFolderInfo/FolderInfoPlugin.cpp index de2b67c30..133dc7036 100644 --- a/Plugins/PluginFolderInfo/FolderInfoPlugin.cpp +++ b/Plugins/PluginFolderInfo/FolderInfoPlugin.cpp @@ -140,9 +140,9 @@ PLUGIN_EXPORT void Finalize(void* data) measure->folder->RemoveInstance(); } - delete measure; - measure = nullptr; - std::vector::iterator iter = std::find(g_Measures.begin(), g_Measures.end(), measure); g_Measures.erase(iter); + + delete measure; + measure = nullptr; } diff --git a/Plugins/PluginPerfMon/PerfData.cpp b/Plugins/PluginPerfMon/PerfData.cpp index 2c4e26c12..414b07a3c 100644 --- a/Plugins/PluginPerfMon/PerfData.cpp +++ b/Plugins/PluginPerfMon/PerfData.cpp @@ -189,11 +189,15 @@ ULONGLONG GetPerfData(LPCWSTR objectName, LPCWSTR instanceName, LPCWSTR counterN break; // No need to continue } - delete pObjInst; - pObjInst = nullptr; + if (pObjInst) + { + delete pObjInst; + pObjInst = nullptr; + } } delete pPerfObj; + pPerfObj = nullptr; } }