Fix compilation errors for VS 16.8.1 (#8024)

* fix compilation issues for VS 16.8.* release

* - VS 16.8 changed its template instantiation model, so now the compiler checks the syntax used in template even when it's not instantiated. we were relying on that behavior to declare the list of required localized strings from a shared header => replacing that template with a macro.

* - fix 3 C++ `const auto&` bugs the new compiler was able to uncover

* - enabled /Zc:twoPhase- for bootstrapper and PowerToysSetupCustomActions to workaround 10.0.17134.0 headers' issue.

- PowerToysSetupCustomActions.vcxproj now uses 10.0.17134.0 instead of "latest" SDK

* - PowerToysSetupCustomActions project leverages `goto` operator's power extensively, and the new compiler was able to uncover new uninitialized variables behavior, restructured declarations and changed `NULL`s to `nullptr`s.

* - Fix unit FZ unit test compiler error

* - format FZS unit test source file

* fixup fz tests

* use /Zc:twoPhase- for common-md as well
This commit is contained in:
Andrey Nekrasov 2020-11-13 15:57:01 +03:00 committed by GitHub
parent 1826b38aa9
commit c1b1fe6371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 143 additions and 136 deletions

View File

@ -14,7 +14,7 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
auto Strings = updating::notifications::strings::create();
auto Strings = create_notifications_strings();
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)

View File

@ -83,6 +83,7 @@
<AdditionalIncludeDirectories>../../../src/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalOptions>/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -104,6 +105,7 @@
<AdditionalIncludeDirectories>../../../src/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalOptions>/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -32,15 +32,21 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
std::wstring wstrTaskName;
ITaskService* pService = NULL;
ITaskFolder* pTaskFolder = NULL;
ITaskDefinition* pTask = NULL;
IRegistrationInfo* pRegInfo = NULL;
ITaskSettings* pSettings = NULL;
ITriggerCollection* pTriggerCollection = NULL;
IRegisteredTask* pRegisteredTask = NULL;
ITaskService* pService = nullptr;
ITaskFolder* pTaskFolder = nullptr;
ITaskDefinition* pTask = nullptr;
IRegistrationInfo* pRegInfo = nullptr;
ITaskSettings* pSettings = nullptr;
ITriggerCollection* pTriggerCollection = nullptr;
IRegisteredTask* pRegisteredTask = nullptr;
IPrincipal * pPrincipal = nullptr;
ITrigger * pTrigger = nullptr;
ILogonTrigger * pLogonTrigger = nullptr;
IAction * pAction = nullptr;
IActionCollection * pActionCollection = nullptr;
IExecAction * pExecAction = nullptr;
LPWSTR wszExecutablePath = NULL;
LPWSTR wszExecutablePath = nullptr;
hr = WcaInitialize(hInstall, "CreateScheduledTaskCA");
ExitOnFailure(hr, "Failed to initialize");
@ -79,7 +85,7 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
// ------------------------------------------------------
// Create an instance of the Task Service.
hr = CoCreateInstance(CLSID_TaskScheduler,
NULL,
nullptr,
CLSCTX_INPROC_SERVER,
IID_ITaskService,
(void**)&pService);
@ -95,7 +101,7 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
if (FAILED(hr))
{
// Folder doesn't exist. Get the Root folder and create the PowerToys subfolder.
ITaskFolder* pRootFolder = NULL;
ITaskFolder* pRootFolder = nullptr;
hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder);
ExitOnFailure(hr, "Cannot get Root Folder pointer: %x", hr);
hr = pRootFolder->CreateFolder(_bstr_t(L"\\PowerToys"), _variant_t(L""), &pTaskFolder);
@ -141,11 +147,9 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
ExitOnFailure(hr, "Cannot get trigger collection: %x", hr);
// Add the logon trigger to the task.
ITrigger* pTrigger = NULL;
hr = pTriggerCollection->Create(TASK_TRIGGER_LOGON, &pTrigger);
ExitOnFailure(hr, "Cannot create the trigger: %x", hr);
ILogonTrigger* pLogonTrigger = NULL;
hr = pTrigger->QueryInterface(
IID_ILogonTrigger, (void**)&pLogonTrigger);
pTrigger->Release();
@ -173,19 +177,17 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
// ------------------------------------------------------
// Add an Action to the task. This task will execute the path passed to this custom action.
IActionCollection* pActionCollection = NULL;
// Get the task action collection pointer.
hr = pTask->get_Actions(&pActionCollection);
ExitOnFailure(hr, "Cannot get Task collection pointer: %x", hr);
// Create the action, specifying that it is an executable action.
IAction* pAction = NULL;
hr = pActionCollection->Create(TASK_ACTION_EXEC, &pAction);
pActionCollection->Release();
ExitOnFailure(hr, "Cannot create the action: %x", hr);
IExecAction* pExecAction = NULL;
// QI for the executable task pointer.
hr = pAction->QueryInterface(
IID_IExecAction, (void**)&pExecAction);
@ -199,7 +201,6 @@ UINT __stdcall CreateScheduledTaskCA(MSIHANDLE hInstall)
// ------------------------------------------------------
// Create the principal for the task
IPrincipal* pPrincipal = NULL;
hr = pTask->get_Principal(&pPrincipal);
ExitOnFailure(hr, "Cannot get principal pointer: %x", hr);
@ -295,9 +296,11 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
ITaskService* pService = NULL;
ITaskFolder* pTaskFolder = NULL;
IRegisteredTaskCollection* pTaskCollection = NULL;
ITaskService* pService = nullptr;
ITaskFolder* pTaskFolder = nullptr;
IRegisteredTaskCollection* pTaskCollection = nullptr;
ITaskFolder * pRootFolder = nullptr;
LONG numTasks = 0;
hr = WcaInitialize(hInstall, "RemoveScheduledTasksCA");
ExitOnFailure(hr, "Failed to initialize");
@ -309,7 +312,7 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
// ------------------------------------------------------
// Create an instance of the Task Service.
hr = CoCreateInstance(CLSID_TaskScheduler,
NULL,
nullptr,
CLSCTX_INPROC_SERVER,
IID_ITaskService,
(void**)&pService);
@ -335,21 +338,20 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
hr = pTaskFolder->GetTasks(TASK_ENUM_HIDDEN, &pTaskCollection);
ExitOnFailure(hr, "Cannot get the registered tasks: %x", hr);
LONG numTasks = 0;
hr = pTaskCollection->get_Count(&numTasks);
for (LONG i = 0; i < numTasks; i++)
{
// Delete all the tasks found.
// If some tasks can't be deleted, the folder won't be deleted later and the user will still be notified.
IRegisteredTask* pRegisteredTask = NULL;
IRegisteredTask* pRegisteredTask = nullptr;
hr = pTaskCollection->get_Item(_variant_t(i + 1), &pRegisteredTask);
if (SUCCEEDED(hr))
{
BSTR taskName = NULL;
BSTR taskName = nullptr;
hr = pRegisteredTask->get_Name(&taskName);
if (SUCCEEDED(hr))
{
hr = pTaskFolder->DeleteTask(taskName, NULL);
hr = pTaskFolder->DeleteTask(taskName, 0);
if (FAILED(hr))
{
WcaLogError(hr, "Cannot delete the '%S' task: %x", taskName, hr);
@ -370,10 +372,9 @@ UINT __stdcall RemoveScheduledTasksCA(MSIHANDLE hInstall)
// ------------------------------------------------------
// Get the pointer to the root task folder and delete the PowerToys subfolder.
ITaskFolder* pRootFolder = NULL;
hr = pService->GetFolder(_bstr_t(L"\\"), &pRootFolder);
ExitOnFailure(hr, "Cannot get Root Folder pointer: %x", hr);
hr = pRootFolder->DeleteFolder(_bstr_t(L"PowerToys"), NULL);
hr = pRootFolder->DeleteFolder(_bstr_t(L"PowerToys"), 0);
pRootFolder->Release();
ExitOnFailure(hr, "Cannot delete the PowerToys folder: %x", hr);

View File

@ -15,7 +15,7 @@
<ProjectGuid>{32f3882b-f2d6-4586-b5ed-11e39e522bd3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PowerToysSetupCustomActions</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
@ -97,6 +97,8 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -20,7 +20,7 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
auto Strings = updating::notifications::strings::create();
auto Strings = create_notifications_strings();
int uninstall_msi_action()
{

View File

@ -61,6 +61,7 @@
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>inc;telemetry;../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -77,6 +78,7 @@
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>inc;telemetry;../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/await /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -29,33 +29,6 @@ namespace updating
std::wstring TOAST_TITLE;
std::wstring OFFER_UNINSTALL_MSI;
std::wstring OFFER_UNINSTALL_MSI_TITLE;
template<typename = void>
static strings create()
{
return strings{
.GITHUB_NEW_VERSION_AVAILABLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_AVAILABLE),
.GITHUB_NEW_VERSION_DOWNLOAD_STARTED = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_DOWNLOAD_STARTED),
.GITHUB_NEW_VERSION_READY_TO_INSTALL = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_READY_TO_INSTALL),
.GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR),
.GITHUB_NEW_VERSION_UPDATE_NOW = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_NOW),
.GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART),
.UNINSTALLATION_UNKNOWN_ERROR = GET_RESOURCE_STRING(IDS_UNINSTALLATION_UNKNOWN_ERROR),
.GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT),
.GITHUB_NEW_VERSION_UNAVAILABLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UNAVAILABLE),
.GITHUB_NEW_VERSION_VISIT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_VISIT),
.GITHUB_NEW_VERSION_MORE_INFO = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_MORE_INFO),
.GITHUB_NEW_VERSION_ABORT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_ABORT),
.GITHUB_NEW_VERSION_SNOOZE_TITLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_SNOOZE_TITLE),
.SNOOZE_BUTTON = GET_RESOURCE_STRING(IDS_SNOOZE_BUTTON),
.GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D),
.GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D),
.DOWNLOAD_IN_PROGRESS = GET_RESOURCE_STRING(IDS_DOWNLOAD_IN_PROGRESS),
.DOWNLOAD_COMPLETE = GET_RESOURCE_STRING(IDS_DOWNLOAD_COMPLETE),
.TOAST_TITLE = GET_RESOURCE_STRING(IDS_TOAST_TITLE),
.OFFER_UNINSTALL_MSI = GET_RESOURCE_STRING(IDS_OFFER_UNINSTALL_MSI),
.OFFER_UNINSTALL_MSI_TITLE = GET_RESOURCE_STRING(IDS_OFFER_UNINSTALL_MSI_TITLE)
};
}
};
void show_unavailable(const notifications::strings& strings);
@ -68,4 +41,30 @@ namespace updating
void update_download_progress(const updating::new_version_download_info& info, float progress, const notifications::strings& strings);
}
}
}
#define create_notifications_strings() \
::updating::notifications::strings \
{ \
.GITHUB_NEW_VERSION_AVAILABLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_AVAILABLE), \
.GITHUB_NEW_VERSION_DOWNLOAD_STARTED = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_DOWNLOAD_STARTED), \
.GITHUB_NEW_VERSION_READY_TO_INSTALL = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_READY_TO_INSTALL), \
.GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_DOWNLOAD_INSTALL_ERROR), \
.GITHUB_NEW_VERSION_UPDATE_NOW = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_NOW), \
.GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_AFTER_RESTART), \
.UNINSTALLATION_UNKNOWN_ERROR = GET_RESOURCE_STRING(IDS_UNINSTALLATION_UNKNOWN_ERROR), \
.GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_AVAILABLE_OFFER_VISIT), \
.GITHUB_NEW_VERSION_UNAVAILABLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UNAVAILABLE), \
.GITHUB_NEW_VERSION_VISIT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_VISIT), \
.GITHUB_NEW_VERSION_MORE_INFO = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_MORE_INFO), \
.GITHUB_NEW_VERSION_ABORT = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_ABORT), \
.GITHUB_NEW_VERSION_SNOOZE_TITLE = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_SNOOZE_TITLE), \
.SNOOZE_BUTTON = GET_RESOURCE_STRING(IDS_SNOOZE_BUTTON), \
.GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_SNOOZE_1D), \
.GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D = GET_RESOURCE_STRING(IDS_GITHUB_NEW_VERSION_UPDATE_SNOOZE_5D), \
.DOWNLOAD_IN_PROGRESS = GET_RESOURCE_STRING(IDS_DOWNLOAD_IN_PROGRESS), \
.DOWNLOAD_COMPLETE = GET_RESOURCE_STRING(IDS_DOWNLOAD_COMPLETE), \
.TOAST_TITLE = GET_RESOURCE_STRING(IDS_TOAST_TITLE), \
.OFFER_UNINSTALL_MSI = GET_RESOURCE_STRING(IDS_OFFER_UNINSTALL_MSI), \
.OFFER_UNINSTALL_MSI_TITLE = GET_RESOURCE_STRING(IDS_OFFER_UNINSTALL_MSI_TITLE) \
}

View File

@ -79,7 +79,7 @@ namespace
if (json.HasKey(NonLocalizable::ZoneIndexSetStr))
{
data.zoneIndexSet = {};
for (auto& value : json.GetNamedArray(NonLocalizable::ZoneIndexSetStr))
for (const auto& value : json.GetNamedArray(NonLocalizable::ZoneIndexSetStr))
{
data.zoneIndexSet.push_back(static_cast<size_t>(value.GetNumber()));
}

View File

@ -420,7 +420,7 @@ namespace FancyZonesUnitTests
IFACEMETHODIMP_(void)
MoveSizeEnd(HWND window, POINT const& ptScreen) noexcept {}
IFACEMETHODIMP_(void)
HandleWinHookEvent(const WinHookEvent * data) noexcept {}
HandleWinHookEvent(const WinHookEvent* data) noexcept {}
IFACEMETHODIMP_(void)
VirtualDesktopChanged() noexcept {}
IFACEMETHODIMP_(void)
@ -559,8 +559,9 @@ namespace FancyZonesUnitTests
m_settings->SetCallback(callback.get());
int bufSize = 0;
m_settings->GetConfig(L"", &bufSize);
int bufSize = 1;
wchar_t buffer{};
m_settings->GetConfig(&buffer, &bufSize);
Assert::IsFalse(flag);
}
@ -622,93 +623,93 @@ namespace FancyZonesUnitTests
}
TEST_METHOD_INITIALIZE(Init)
{
HINSTANCE hInst = (HINSTANCE)GetModuleHandleW(nullptr);
{
HINSTANCE hInst = (HINSTANCE)GetModuleHandleW(nullptr);
m_settings = MakeFancyZonesSettings(hInst, m_moduleName, m_moduleKey);
Assert::IsTrue(m_settings != nullptr);
}
m_settings = MakeFancyZonesSettings(hInst, m_moduleName, m_moduleKey);
Assert::IsTrue(m_settings != nullptr);
}
TEST_METHOD_CLEANUP(Cleanup)
{
std::filesystem::remove_all(PTSettingsHelper::get_module_save_folder_location(m_moduleName));
}
TEST_METHOD_CLEANUP(Cleanup)
{
std::filesystem::remove_all(PTSettingsHelper::get_module_save_folder_location(m_moduleName));
}
TEST_METHOD (GetConfig)
{
int expectedSize = 0;
m_settings->GetConfig(nullptr, &expectedSize);
Assert::AreNotEqual(0, expectedSize);
TEST_METHOD (GetConfig)
{
int expectedSize = 0;
m_settings->GetConfig(nullptr, &expectedSize);
Assert::AreNotEqual(0, expectedSize);
int actualBufferSize = expectedSize;
PWSTR actualBuffer = new wchar_t[actualBufferSize];
int actualBufferSize = expectedSize;
PWSTR actualBuffer = new wchar_t[actualBufferSize];
Assert::IsTrue(m_settings->GetConfig(actualBuffer, &actualBufferSize));
Assert::AreEqual(expectedSize, actualBufferSize);
}
Assert::IsTrue(m_settings->GetConfig(actualBuffer, &actualBufferSize));
Assert::AreEqual(expectedSize, actualBufferSize);
}
TEST_METHOD (GetConfigSmallBuffer)
{
int size = 0;
m_settings->GetConfig(nullptr, &size);
Assert::AreNotEqual(0, size);
TEST_METHOD (GetConfigSmallBuffer)
{
int size = 0;
m_settings->GetConfig(nullptr, &size);
Assert::AreNotEqual(0, size);
int actualBufferSize = size - 1;
PWSTR actualBuffer = new wchar_t[actualBufferSize];
int actualBufferSize = size - 1;
PWSTR actualBuffer = new wchar_t[actualBufferSize];
Assert::IsFalse(m_settings->GetConfig(actualBuffer, &actualBufferSize));
Assert::AreEqual(size, actualBufferSize);
}
Assert::IsFalse(m_settings->GetConfig(actualBuffer, &actualBufferSize));
Assert::AreEqual(size, actualBufferSize);
}
TEST_METHOD (GetConfigNullBuffer)
{
int expectedSize = 0;
m_settings->GetConfig(nullptr, &expectedSize);
Assert::AreNotEqual(0, expectedSize);
TEST_METHOD (GetConfigNullBuffer)
{
int expectedSize = 0;
m_settings->GetConfig(nullptr, &expectedSize);
Assert::AreNotEqual(0, expectedSize);
int actualBufferSize = 0;
int actualBufferSize = 0;
Assert::IsFalse(m_settings->GetConfig(nullptr, &actualBufferSize));
Assert::AreEqual(expectedSize, actualBufferSize);
}
Assert::IsFalse(m_settings->GetConfig(nullptr, &actualBufferSize));
Assert::AreEqual(expectedSize, actualBufferSize);
}
TEST_METHOD (SetConfig)
{
//cleanup file before call set config
const auto settingsFile = PTSettingsHelper::get_module_save_folder_location(m_moduleName) + L"\\settings.json";
std::filesystem::remove(settingsFile);
TEST_METHOD (SetConfig)
{
//cleanup file before call set config
const auto settingsFile = PTSettingsHelper::get_module_save_folder_location(m_moduleName) + L"\\settings.json";
std::filesystem::remove(settingsFile);
const Settings expected{
.shiftDrag = true,
.mouseSwitch = true,
.displayChange_moveWindows = true,
.zoneSetChange_flashZones = false,
.zoneSetChange_moveWindows = true,
.overrideSnapHotkeys = false,
.moveWindowAcrossMonitors = false,
.appLastZone_moveWindows = true,
.openWindowOnActiveMonitor = false,
.restoreSize = false,
.use_cursorpos_editor_startupscreen = true,
.showZonesOnAllMonitors = false,
.spanZonesAcrossMonitors = false,
.makeDraggedWindowTransparent = true,
.zoneColor = L"#FAFAFA",
.zoneBorderColor = L"CCDDEE",
.zoneHighlightColor = L"#00AABB",
.zoneHighlightOpacity = 45,
.editorHotkey = PowerToysSettings::HotkeyObject::from_settings(false, false, false, false, VK_OEM_3),
.excludedApps = L"app\r\napp2",
.excludedAppsArray = { L"APP", L"APP2" },
};
const Settings expected{
.shiftDrag = true,
.mouseSwitch = true,
.displayChange_moveWindows = true,
.zoneSetChange_flashZones = false,
.zoneSetChange_moveWindows = true,
.overrideSnapHotkeys = false,
.moveWindowAcrossMonitors = false,
.appLastZone_moveWindows = true,
.openWindowOnActiveMonitor = false,
.restoreSize = false,
.use_cursorpos_editor_startupscreen = true,
.showZonesOnAllMonitors = false,
.spanZonesAcrossMonitors = false,
.makeDraggedWindowTransparent = true,
.zoneColor = L"#FAFAFA",
.zoneBorderColor = L"CCDDEE",
.zoneHighlightColor = L"#00AABB",
.zoneHighlightOpacity = 45,
.editorHotkey = PowerToysSettings::HotkeyObject::from_settings(false, false, false, false, VK_OEM_3),
.excludedApps = L"app\r\napp2",
.excludedAppsArray = { L"APP", L"APP2" },
};
auto config = serializedPowerToySettings(expected);
m_settings->SetConfig(config.c_str());
auto config = serializedPowerToySettings(expected);
m_settings->SetConfig(config.c_str());
auto actual = m_settings->GetSettings();
compareSettings(expected, *actual);
auto actual = m_settings->GetSettings();
compareSettings(expected, *actual);
Assert::IsTrue(std::filesystem::exists(settingsFile));
}
Assert::IsTrue(std::filesystem::exists(settingsFile));
}
};
}

View File

@ -16,7 +16,7 @@ namespace KeyboardEventHandlers
// Check if the key event was generated by KeyboardManager to avoid remapping events generated by us.
if (!(data->lParam->dwExtraInfo & CommonSharedConstants::KEYBOARDMANAGER_INJECTED_FLAG))
{
auto& remapping = keyboardManagerState.GetSingleKeyRemap(data->lParam->vkCode);
const auto remapping = keyboardManagerState.GetSingleKeyRemap(data->lParam->vkCode);
if (remapping)
{
auto it = remapping.value();
@ -187,7 +187,7 @@ namespace KeyboardEventHandlers
// Iterate through the shortcut remaps and apply whichever has been pressed
for (auto& itShortcut : keyboardManagerState.GetSortedShortcutRemapVector(activatedApp))
{
auto& it = reMap.find(itShortcut);
const auto it = reMap.find(itShortcut);
// If a shortcut is currently in the invoked state then skip till the shortcut that is currently invoked
if (isShortcutInvoked && !it->second.isShortcutInvoked)

View File

@ -13,7 +13,7 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
auto Strings = updating::notifications::strings::create();
auto Strings = create_notifications_strings();
bool start_msi_uninstallation_sequence()
{