[runner] removed outdated MSIX code (#11450)

This commit is contained in:
Enrico Giordani 2021-06-03 14:20:11 -07:00 committed by GitHub
parent e69cd8a057
commit 367b3df705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 73 deletions

View file

@ -11,7 +11,6 @@
namespace
{
constexpr inline wchar_t POWERTOYS_MSI_MUTEX_NAME[] = L"Local\\PowerToys_Runner_MSI_InstanceMutex";
constexpr inline wchar_t POWERTOYS_MSIX_MUTEX_NAME[] = L"Local\\PowerToys_Runner_MSIX_InstanceMutex";
constexpr inline wchar_t POWERTOYS_BOOTSTRAPPER_MUTEX_NAME[] = L"Local\\PowerToys_Bootstrapper_InstanceMutex";
}

View file

@ -70,11 +70,6 @@ inline wil::unique_mutex_nothrow create_msi_mutex()
return createAppMutex(POWERTOYS_MSI_MUTEX_NAME);
}
inline wil::unique_mutex_nothrow create_msix_mutex()
{
return createAppMutex(POWERTOYS_MSIX_MUTEX_NAME);
}
void open_menu_from_another_instance()
{
const HWND hwnd_main = FindWindowW(L"PToyTrayIconWindow", nullptr);
@ -330,69 +325,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
logFilePath.append(LogSettings::runnerLogPath);
Logger::init(LogSettings::runnerLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
wil::unique_mutex_nothrow msi_mutex;
wil::unique_mutex_nothrow msix_mutex;
if (winstore::running_as_packaged())
// Check if another instance is already running.
wil::unique_mutex_nothrow msi_mutex = create_msi_mutex();
if (!msi_mutex)
{
msix_mutex = create_msix_mutex();
if (!msix_mutex)
{
// The MSIX version is already running.
open_menu_from_another_instance();
return 0;
}
// Check if the MSI version is running, if not, hold the
// mutex to prevent the old MSI versions to start.
msi_mutex = create_msi_mutex();
if (!msi_mutex)
{
// The MSI version is running, warn the user and offer to uninstall it.
const bool declined_uninstall = !start_msi_uninstallation_sequence();
if (declined_uninstall)
{
// Check again if the MSI version is still running.
msi_mutex = create_msi_mutex();
if (!msi_mutex)
{
open_menu_from_another_instance();
return 0;
}
}
}
else
{
// Older MSI versions are not aware of the MSIX mutex, therefore
// hold the MSI mutex to prevent an old instance to start.
}
}
else
{
// Check if another instance of the MSI version is already running.
msi_mutex = create_msi_mutex();
if (!msi_mutex)
{
// The MSI version is already running.
open_menu_from_another_instance();
return 0;
}
// Check if an instance of the MSIX version is already running.
// Note: this check should always be negative since the MSIX version
// is holding both mutexes.
msix_mutex = create_msix_mutex();
if (!msix_mutex)
{
// The MSIX version is already running.
open_menu_from_another_instance();
return 0;
}
else
{
// The MSIX version isn't running, release the mutex.
msix_mutex.reset(nullptr);
}
open_menu_from_another_instance();
return 0;
}
bool openOobe = false;
@ -448,11 +386,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
msi_mutex.reset(nullptr);
}
if (msix_mutex)
{
msix_mutex.reset(nullptr);
}
if (is_restart_scheduled())
{
if (restart_if_scheduled() == false)