notifications: provide default app id to fix FZ toast crashes (#5551)

This commit is contained in:
Andrey Nekrasov 2020-08-04 11:12:49 +03:00 committed by GitHub
parent 1456be9feb
commit 371523d756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 7 deletions

View File

@ -90,7 +90,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
return 1;
}
notifications::set_application_id(APPLICATION_ID);
notifications::override_application_id(APPLICATION_ID);
fs::path iconPath{ L"C:\\" };
if (auto extractedIcon = extractIcon())

View File

@ -30,6 +30,7 @@ using winrt::Windows::UI::Notifications::ToastNotificationManager;
namespace fs = std::filesystem;
// This namespace contains strings that SHOULD NOT be localized
namespace
{
constexpr std::wstring_view TASK_NAME = L"PowerToysBackgroundNotificationsHandler";
@ -37,7 +38,7 @@ namespace
constexpr std::wstring_view PACKAGED_APPLICATION_ID = L"PowerToys";
constexpr std::wstring_view APPIDS_REGISTRY = LR"(Software\Classes\AppUserModelId\)";
std::wstring APPLICATION_ID;
std::wstring APPLICATION_ID = L"Microsoft.PowerToysWin32";
}
namespace localized_strings
@ -184,7 +185,7 @@ void notifications::unregister_application_id()
RegDeleteKeyW(registryRoot.get(), APPLICATION_ID.data());
}
void notifications::set_application_id(const std::wstring_view appID)
void notifications::override_application_id(const std::wstring_view appID)
{
APPLICATION_ID = appID;
SetCurrentProcessExplicitAppUserModelID(APPLICATION_ID.c_str());

View File

@ -10,7 +10,7 @@ namespace notifications
{
constexpr inline const wchar_t TOAST_ACTIVATED_LAUNCH_ARG[] = L"-ToastActivated";
void set_application_id(const std::wstring_view appID);
void override_application_id(const std::wstring_view appID);
void register_background_toast_handler();
void run_desktop_app_activator_loop();

View File

@ -48,7 +48,6 @@ namespace localized_strings
namespace
{
const wchar_t PT_URI_PROTOCOL_SCHEME[] = L"powertoys://";
const wchar_t APPLICATION_ID[] = L"Microsoft.PowerToysWin32";
}
void chdir_current_executable()
@ -305,8 +304,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
{
return 0;
}
notifications::set_application_id(APPLICATION_ID);
int n_cmd_args = 0;
LPWSTR* cmd_arg_list = CommandLineToArgvW(GetCommandLineW(), &n_cmd_args);
switch (should_run_in_special_mode(n_cmd_args, cmd_arg_list))