From 3a03ff034f5013a91e12303bf992a0aafbd3f1f0 Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Fri, 28 Jul 2023 17:23:54 +0200 Subject: [PATCH] [Runner]Delay update toast for Windows to refresh toast settings (#27671) --- src/runner/main.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 1adf8fd1c624..9d0e1f5e440c 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -91,7 +91,7 @@ void open_menu_from_another_instance(std::optional settings_window) int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow, bool openOobe, bool openScoobe) { - Logger::info("Runner is starting. Elevated={}", isProcessElevated); + Logger::info("Runner is starting. Elevated={} openOobe={} openScoobe={}", isProcessElevated, openOobe, openScoobe); DPIAware::EnableDPIAwarenessForThisProcess(); #if _DEBUG && _WIN64 @@ -108,7 +108,14 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow { if (!openOobe && openScoobe) { - notifications::show_toast(GET_RESOURCE_STRING(IDS_PT_VERSION_CHANGE_ASK_FOR_COMPUTER_RESTART).c_str(), L"PowerToys"); + std::thread{ + [] { + // Wait a bit, because Windows has a delay until it picks up toast notification registration in the registry + Sleep(10000); + Logger::info("Showing toast notification asking to restart PC"); + notifications::show_toast(GET_RESOURCE_STRING(IDS_PT_VERSION_CHANGE_ASK_FOR_COMPUTER_RESTART).c_str(), L"PowerToys"); + } + }.detach(); } std::thread{ [] { @@ -430,7 +437,9 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR l try { std::wstring last_version_run = PTSettingsHelper::get_last_version_run(); - openScoobe = last_version_run != get_product_version(); + const auto product_version = get_product_version(); + openScoobe = product_version != last_version_run; + Logger::info(L"Scoobe: product_version={} last_version_run={}", product_version, last_version_run); } catch (const std::exception& e) {