mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[Analyzers][CPP] Turn on warning 4702 (#22285)
* Turn on 4702 unreachable code * fix warnings that didnt show locally * add comments about disable warnings * improve comments * changes from comments * fix from PR comments
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level4</WarningLevel>
|
||||||
<DisableSpecificWarnings>4679;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4679;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
|
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
|
||||||
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
||||||
<ConformanceMode>false</ConformanceMode>
|
<ConformanceMode>false</ConformanceMode>
|
||||||
|
|||||||
@@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
#define HKEY_WINDOWS_THEME L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
|
#define HKEY_WINDOWS_THEME L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
|
||||||
|
|
||||||
|
// disabling warning 4702 - unreachable code
|
||||||
|
// prevent the warning after the call off a infinite loop function
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4702)
|
||||||
DWORD WINAPI _checkTheme(LPVOID lpParam)
|
DWORD WINAPI _checkTheme(LPVOID lpParam)
|
||||||
{
|
{
|
||||||
auto listener = (ThemeListener*)lpParam;
|
auto listener = (ThemeListener*)lpParam;
|
||||||
listener->CheckTheme();
|
listener->CheckTheme();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
void ThemeListener::AddChangedHandler(THEME_HANDLE handle)
|
void ThemeListener::AddChangedHandler(THEME_HANDLE handle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ namespace updating
|
|||||||
throw std::runtime_error("Release object doesn't have the required asset");
|
throw std::runtime_error("Release object doesn't have the required asset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disabling warning 4702 - unreachable code
|
||||||
|
// prevent the warning that may show up depend on the value of the constants (#defines)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4702)
|
||||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||||
{
|
{
|
||||||
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
||||||
@@ -126,6 +130,7 @@ namespace updating
|
|||||||
}
|
}
|
||||||
co_return nonstd::make_unexpected(NETWORK_ERROR);
|
co_return nonstd::make_unexpected(NETWORK_ERROR);
|
||||||
}
|
}
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
std::filesystem::path get_pending_updates_path()
|
std::filesystem::path get_pending_updates_path()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ public:
|
|||||||
// These are the settings shown on the settings page along with their current values.
|
// These are the settings shown on the settings page along with their current values.
|
||||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||||
|
|
||||||
// Create a Settings object.
|
// Create a Settings object.
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ private:
|
|||||||
void RegisterVirtualDesktopUpdates() noexcept;
|
void RegisterVirtualDesktopUpdates() noexcept;
|
||||||
|
|
||||||
void UpdateHotkey(int hotkeyId, const PowerToysSettings::HotkeyObject& hotkeyObject, bool enable) noexcept;
|
void UpdateHotkey(int hotkeyId, const PowerToysSettings::HotkeyObject& hotkeyObject, bool enable) noexcept;
|
||||||
|
|
||||||
std::pair<std::shared_ptr<WorkArea>, ZoneIndexSet> GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept;
|
std::pair<std::shared_ptr<WorkArea>, ZoneIndexSet> GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept;
|
||||||
void MoveWindowIntoZone(HWND window, std::shared_ptr<WorkArea> workArea, const ZoneIndexSet& zoneIndexSet) noexcept;
|
void MoveWindowIntoZone(HWND window, std::shared_ptr<WorkArea> workArea, const ZoneIndexSet& zoneIndexSet) noexcept;
|
||||||
bool MoveToAppLastZone(HWND window, HMONITOR active, HMONITOR primary) noexcept;
|
bool MoveToAppLastZone(HWND window, HMONITOR active, HMONITOR primary) noexcept;
|
||||||
@@ -333,7 +333,7 @@ std::pair<std::shared_ptr<WorkArea>, ZoneIndexSet> FancyZones::GetAppZoneHistory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::pair<std::shared_ptr<WorkArea>, ZoneIndexSet>{ nullptr, {} };
|
return std::pair<std::shared_ptr<WorkArea>, ZoneIndexSet>{ nullptr, {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ void FancyZones::MoveWindowIntoZone(HWND window, std::shared_ptr<WorkArea> workA
|
|||||||
{
|
{
|
||||||
if (workArea)
|
if (workArea)
|
||||||
{
|
{
|
||||||
Trace::FancyZones::SnapNewWindowIntoZone(workArea->GetLayout().get(), workArea->GetLayoutWindows().get());
|
Trace::FancyZones::SnapNewWindowIntoZone(workArea->GetLayout().get(), workArea->GetLayoutWindows().get());
|
||||||
}
|
}
|
||||||
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, workArea);
|
m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, workArea);
|
||||||
AppZoneHistory::instance().UpdateProcessIdToHandleMap(window, workArea->UniqueId());
|
AppZoneHistory::instance().UpdateProcessIdToHandleMap(window, workArea->UniqueId());
|
||||||
@@ -413,7 +413,6 @@ void FancyZones::WindowCreated(HWND window) noexcept
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HMONITOR primary = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
|
HMONITOR primary = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
|
||||||
HMONITOR active = primary;
|
HMONITOR active = primary;
|
||||||
@@ -505,7 +504,7 @@ FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
|
|||||||
void FancyZones::ToggleEditor() noexcept
|
void FancyZones::ToggleEditor() noexcept
|
||||||
{
|
{
|
||||||
_TRACER_;
|
_TRACER_;
|
||||||
|
|
||||||
if (m_terminateEditorEvent)
|
if (m_terminateEditorEvent)
|
||||||
{
|
{
|
||||||
SetEvent(m_terminateEditorEvent.get());
|
SetEvent(m_terminateEditorEvent.get());
|
||||||
@@ -519,7 +518,7 @@ void FancyZones::ToggleEditor() noexcept
|
|||||||
Logger::error(L"Failed to save editor startup parameters");
|
Logger::error(L"Failed to save editor startup parameters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELLEXECUTEINFO sei{ sizeof(sei) };
|
SHELLEXECUTEINFO sei{ sizeof(sei) };
|
||||||
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
|
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
|
||||||
sei.lpFile = NonLocalizable::FZEditorExecutablePath;
|
sei.lpFile = NonLocalizable::FZEditorExecutablePath;
|
||||||
@@ -553,7 +552,6 @@ void FancyZones::ToggleEditor() noexcept
|
|||||||
waitForEditorThread.detach();
|
waitForEditorThread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) noexcept
|
LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) noexcept
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
@@ -714,7 +712,7 @@ void FancyZones::OnDisplayChange(DisplayChangeType changeType) noexcept
|
|||||||
|
|
||||||
UpdateWorkAreas();
|
UpdateWorkAreas();
|
||||||
|
|
||||||
auto activeWorkAreas = m_workAreaHandler.GetWorkAreasByDesktopId(VirtualDesktop::instance().GetCurrentVirtualDesktopId());
|
auto activeWorkAreas = m_workAreaHandler.GetWorkAreasByDesktopId(VirtualDesktop::instance().GetCurrentVirtualDesktopId());
|
||||||
m_windowMoveHandler.AssignWindowsToZones(activeWorkAreas, FancyZonesSettings::settings().displayChange_moveWindows && changeType != DisplayChangeType::VirtualDesktop);
|
m_windowMoveHandler.AssignWindowsToZones(activeWorkAreas, FancyZonesSettings::settings().displayChange_moveWindows && changeType != DisplayChangeType::VirtualDesktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,7 +725,7 @@ void FancyZones::AddWorkArea(HMONITOR monitor, const FancyZonesDataTypes::WorkAr
|
|||||||
{
|
{
|
||||||
Logger::debug(L"Add new work area on virtual desktop {}", virtualDesktopIdStr.get());
|
Logger::debug(L"Add new work area on virtual desktop {}", virtualDesktopIdStr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyZonesDataTypes::WorkAreaId parentId{};
|
FancyZonesDataTypes::WorkAreaId parentId{};
|
||||||
auto parentArea = m_workAreaHandler.GetWorkArea(VirtualDesktop::instance().GetPreviousVirtualDesktopId(), monitor);
|
auto parentArea = m_workAreaHandler.GetWorkArea(VirtualDesktop::instance().GetPreviousVirtualDesktopId(), monitor);
|
||||||
if (parentArea)
|
if (parentArea)
|
||||||
@@ -1007,11 +1005,8 @@ bool FancyZones::OnSnapHotkey(DWORD vkCode) noexcept
|
|||||||
{
|
{
|
||||||
return OnSnapHotkeyBasedOnPosition(window, vkCode);
|
return OnSnapHotkeyBasedOnPosition(window, vkCode);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return (vkCode == VK_LEFT || vkCode == VK_RIGHT) && OnSnapHotkeyBasedOnZoneNumber(window, vkCode);
|
||||||
return (vkCode == VK_LEFT || vkCode == VK_RIGHT) && OnSnapHotkeyBasedOnZoneNumber(window, vkCode);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle, std::shared_ptr<WorkArea> workArea) noexcept
|
bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle, std::shared_ptr<WorkArea> workArea) noexcept
|
||||||
@@ -1020,7 +1015,7 @@ bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle
|
|||||||
if (GetAsyncKeyState(VK_MENU) & 0x8000)
|
if (GetAsyncKeyState(VK_MENU) & 0x8000)
|
||||||
{
|
{
|
||||||
bool result = m_windowMoveHandler.ExtendWindowByDirectionAndPosition(window, vkCode, workArea);
|
bool result = m_windowMoveHandler.ExtendWindowByDirectionAndPosition(window, vkCode, workArea);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Trace::FancyZones::KeyboardSnapWindowToZone(workArea->GetLayout().get(), workArea->GetLayoutWindows().get());
|
Trace::FancyZones::KeyboardSnapWindowToZone(workArea->GetLayout().get(), workArea->GetLayoutWindows().get());
|
||||||
}
|
}
|
||||||
@@ -1128,12 +1123,12 @@ void FancyZones::UpdateZoneSets() noexcept
|
|||||||
bool FancyZones::ShouldProcessSnapHotkey(DWORD vkCode) noexcept
|
bool FancyZones::ShouldProcessSnapHotkey(DWORD vkCode) noexcept
|
||||||
{
|
{
|
||||||
auto window = GetForegroundWindow();
|
auto window = GetForegroundWindow();
|
||||||
|
|
||||||
if (!FancyZonesWindowProcessing::IsProcessable(window))
|
if (!FancyZonesWindowProcessing::IsProcessable(window))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FancyZonesSettings::settings().overrideSnapHotkeys && FancyZonesWindowUtils::IsCandidateForZoning(window))
|
if (FancyZonesSettings::settings().overrideSnapHotkeys && FancyZonesWindowUtils::IsCandidateForZoning(window))
|
||||||
{
|
{
|
||||||
HMONITOR monitor = WorkAreaKeyFromWindow(window);
|
HMONITOR monitor = WorkAreaKeyFromWindow(window);
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-app-zone-history.json";
|
return saveFolderPath + L"\\test-app-zone-history.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\app-zone-history.json";
|
return saveFolderPath + L"\\app-zone-history.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class AppliedLayouts
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using TAppliedLayoutsMap = std::unordered_map<FancyZonesDataTypes::WorkAreaId, LayoutData>;
|
using TAppliedLayoutsMap = std::unordered_map<FancyZonesDataTypes::WorkAreaId, LayoutData>;
|
||||||
|
|
||||||
static AppliedLayouts& instance();
|
static AppliedLayouts& instance();
|
||||||
|
|
||||||
inline static std::wstring AppliedLayoutsFileName()
|
inline static std::wstring AppliedLayoutsFileName()
|
||||||
@@ -44,8 +44,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-applied-layouts.json";
|
return saveFolderPath + L"\\test-applied-layouts.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\applied-layouts.json";
|
return saveFolderPath + L"\\applied-layouts.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-custom-layouts.json";
|
return saveFolderPath + L"\\test-custom-layouts.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\custom-layouts.json";
|
return saveFolderPath + L"\\custom-layouts.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <FancyZonesLib/FancyZonesData/LayoutData.h>
|
#include <FancyZonesLib/FancyZonesData/LayoutData.h>
|
||||||
#include <FancyZonesLib/ModuleConstants.h>
|
#include <FancyZonesLib/ModuleConstants.h>
|
||||||
|
|
||||||
#include <common/SettingsAPI/FileWatcher.h>
|
#include <common/SettingsAPI/FileWatcher.h>
|
||||||
#include <common/SettingsAPI/settings_helpers.h>
|
#include <common/SettingsAPI/settings_helpers.h>
|
||||||
|
|
||||||
@@ -40,8 +39,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-default-layouts.json";
|
return saveFolderPath + L"\\test-default-layouts.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\default-layouts.json";
|
return saveFolderPath + L"\\default-layouts.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-layout-hotkeys.json";
|
return saveFolderPath + L"\\test-layout-hotkeys.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\layout-hotkeys.json";
|
return saveFolderPath + L"\\layout-hotkeys.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|
||||||
std::optional<GUID> GetLayoutId(int key) const noexcept;
|
std::optional<GUID> GetLayoutId(int key) const noexcept;
|
||||||
size_t GetHotkeysCount() const noexcept;
|
size_t GetHotkeysCount() const noexcept;
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-layout-templates.json";
|
return saveFolderPath + L"\\test-layout-templates.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\layout-templates.json";
|
return saveFolderPath + L"\\layout-templates.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadData();
|
void LoadData();
|
||||||
|
|||||||
@@ -74,8 +74,9 @@ public:
|
|||||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||||
#if defined(UNIT_TESTS)
|
#if defined(UNIT_TESTS)
|
||||||
return saveFolderPath + L"\\test-settings.json";
|
return saveFolderPath + L"\\test-settings.json";
|
||||||
#endif
|
#else
|
||||||
return saveFolderPath + L"\\settings.json";
|
return saveFolderPath + L"\\settings.json";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddObserver(SettingsObserver& observer);
|
void AddObserver(SettingsObserver& observer);
|
||||||
|
|||||||
Reference in New Issue
Block a user