diff --git a/src/modules/powerrename/lib/Settings.cpp b/src/modules/powerrename/lib/Settings.cpp index c2b57187d9..c8d8da7f9d 100644 --- a/src/modules/powerrename/lib/Settings.cpp +++ b/src/modules/powerrename/lib/Settings.cpp @@ -29,7 +29,7 @@ namespace const wchar_t c_mruList[] = L"MRUList"; const wchar_t c_insertionIdx[] = L"InsertionIdx"; - long GetRegNumber(const std::wstring& valueName, long defaultValue) + unsigned int GetRegNumber(const std::wstring& valueName, unsigned int defaultValue) { DWORD type = REG_DWORD; DWORD data = 0; @@ -41,7 +41,7 @@ namespace return defaultValue; } - void SetRegNumber(const std::wstring& valueName, long value) + void SetRegNumber(const std::wstring& valueName, unsigned int value) { SHSetValue(HKEY_CURRENT_USER, c_rootRegPath, valueName.c_str(), REG_DWORD, &value, sizeof(value)); } @@ -86,7 +86,7 @@ namespace class MRUListHandler { public: - MRUListHandler(int size, const std::wstring& filePath, const std::wstring& regPath) : + MRUListHandler(unsigned int size, const std::wstring& filePath, const std::wstring& regPath) : pushIdx(0), nextIdx(1), size(size), @@ -112,9 +112,9 @@ private: bool Exists(const std::wstring& data); std::vector items; - long pushIdx; - long nextIdx; - long size; + unsigned int pushIdx; + unsigned int nextIdx; + unsigned int size; const std::wstring jsonFilePath; const std::wstring registryFilePath; }; @@ -140,7 +140,7 @@ bool MRUListHandler::Next(std::wstring& data) return false; } // Go backwards to consume latest items first. - long idx = (pushIdx + size - nextIdx) % size; + unsigned int idx = (pushIdx + size - nextIdx) % size; if (items[idx].empty()) { Reset(); @@ -212,15 +212,15 @@ void MRUListHandler::ParseJson() const json::JsonObject& jsonObject = json.value(); try { - long oldSize{ size }; + unsigned int oldSize{ size }; if (json::has(jsonObject, c_maxMRUSize, json::JsonValueType::Number)) { - oldSize = (long)jsonObject.GetNamedNumber(c_maxMRUSize); + oldSize = (unsigned int)jsonObject.GetNamedNumber(c_maxMRUSize); } - long oldPushIdx{ 0 }; + unsigned int oldPushIdx{ 0 }; if (json::has(jsonObject, c_insertionIdx, json::JsonValueType::Number)) { - oldPushIdx = (long)jsonObject.GetNamedNumber(c_insertionIdx); + oldPushIdx = (unsigned int)jsonObject.GetNamedNumber(c_insertionIdx); if (oldPushIdx < 0 || oldPushIdx >= oldSize) { oldPushIdx = 0; @@ -240,7 +240,7 @@ void MRUListHandler::ParseJson() else { std::vector temp; - for (uint32_t i = 0; i < min(jsonArray.Size(), size); ++i) + for (unsigned int i = 0; i < min(jsonArray.Size(), size); ++i) { int idx = (oldPushIdx + oldSize - (i + 1)) % oldSize; temp.push_back(std::wstring(jsonArray.GetStringAt(idx))); @@ -248,7 +248,7 @@ void MRUListHandler::ParseJson() if (size > oldSize) { std::reverse(std::begin(temp), std::end(temp)); - pushIdx = (long)temp.size(); + pushIdx = (unsigned int)temp.size(); temp.resize(size); } else @@ -295,7 +295,7 @@ private: CRenameMRU(int size, const std::wstring& filePath, const std::wstring& regPath); std::unique_ptr mruList; - long refCount = 0; + unsigned int refCount = 0; }; CRenameMRU::CRenameMRU(int size, const std::wstring& filePath, const std::wstring& regPath) : @@ -307,7 +307,7 @@ CRenameMRU::CRenameMRU(int size, const std::wstring& filePath, const std::wstrin HRESULT CRenameMRU::CreateInstance(_In_ const std::wstring& filePath, _In_ const std::wstring& regPath, _Outptr_ IUnknown** ppUnk) { *ppUnk = nullptr; - long maxMRUSize = CSettingsInstance().GetMaxMRUSize(); + unsigned int maxMRUSize = CSettingsInstance().GetMaxMRUSize(); HRESULT hr = maxMRUSize > 0 ? S_OK : E_FAIL; if (SUCCEEDED(hr)) { @@ -330,7 +330,7 @@ IFACEMETHODIMP_(ULONG) CRenameMRU::AddRef() IFACEMETHODIMP_(ULONG) CRenameMRU::Release() { - long cnt = InterlockedDecrement(&refCount); + unsigned int cnt = InterlockedDecrement(&refCount); if (cnt == 0) { @@ -485,11 +485,11 @@ void CSettings::ParseJson() } if (json::has(jsonSettings, c_maxMRUSize, json::JsonValueType::Number)) { - settings.maxMRUSize = (long)jsonSettings.GetNamedNumber(c_maxMRUSize); + settings.maxMRUSize = (unsigned int)jsonSettings.GetNamedNumber(c_maxMRUSize); } if (json::has(jsonSettings, c_flags, json::JsonValueType::Number)) { - settings.flags = (long)jsonSettings.GetNamedNumber(c_flags); + settings.flags = (unsigned int)jsonSettings.GetNamedNumber(c_flags); } if (json::has(jsonSettings, c_searchText, json::JsonValueType::String)) { diff --git a/src/modules/powerrename/lib/Settings.h b/src/modules/powerrename/lib/Settings.h index e82c5c0b65..5af4f8a6a1 100644 --- a/src/modules/powerrename/lib/Settings.h +++ b/src/modules/powerrename/lib/Settings.h @@ -61,22 +61,22 @@ public: settings.MRUEnabled = MRUEnabled; } - inline long GetMaxMRUSize() const + inline unsigned int GetMaxMRUSize() const { return settings.maxMRUSize; } - inline void SetMaxMRUSize(long maxMRUSize) + inline void SetMaxMRUSize(unsigned int maxMRUSize) { settings.maxMRUSize = maxMRUSize; } - inline long GetFlags() const + inline unsigned int GetFlags() const { return settings.flags; } - inline void SetFlags(long flags) + inline void SetFlags(unsigned int flags) { settings.flags = flags; Save(); @@ -115,8 +115,8 @@ private: bool extendedContextMenuOnly{ false }; // Disabled by default. bool persistState{ true }; bool MRUEnabled{ true }; - long maxMRUSize{ 10 }; - long flags{ 0 }; + unsigned int maxMRUSize{ 10 }; + unsigned int flags{ 0 }; std::wstring searchText{}; std::wstring replaceText{}; };