mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
PowerToys Run cache issue (#4472)
* Clean termination of powertoys process. * Fixed issue with run not responding to WM_CLOSE * Fixed serialization error in pinyin and image cache * Fixed merge conflict * Fixed nit wrt to master * Fixed undeterministic behaviour of Environment.Exit function * Update timing for terminate process
This commit is contained in:
committed by
GitHub
parent
aad2e8012b
commit
92fa8b7421
@@ -45,6 +45,10 @@ private:
|
||||
//contains the name of the powerToys
|
||||
std::wstring app_name;
|
||||
|
||||
// Time to wait for process to close after sending WM_CLOSE signal
|
||||
static const int MAX_WAIT_MILLISEC = 10000;
|
||||
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Microsoft_Launcher() {
|
||||
@@ -55,7 +59,7 @@ public:
|
||||
~Microsoft_Launcher() {
|
||||
if (m_enabled)
|
||||
{
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
terminateProcess();
|
||||
}
|
||||
m_enabled = false;
|
||||
}
|
||||
@@ -201,8 +205,8 @@ public:
|
||||
virtual void disable()
|
||||
{
|
||||
if (m_enabled)
|
||||
{
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
{
|
||||
terminateProcess();
|
||||
}
|
||||
|
||||
m_enabled = false;
|
||||
@@ -229,6 +233,28 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Callback to send WM_CLOSE signal to each top level window.
|
||||
static BOOL CALLBACK requestMainWindowClose(HWND nextWindow, LPARAM closePid) {
|
||||
DWORD windowPid;
|
||||
GetWindowThreadProcessId(nextWindow, &windowPid);
|
||||
|
||||
if (windowPid == (DWORD)closePid)
|
||||
::PostMessage(nextWindow, WM_CLOSE, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Terminate process by sending WM_CLOSE signal and if it fails, force terminate.
|
||||
void terminateProcess() {
|
||||
DWORD processID = GetProcessId(m_hProcess);
|
||||
EnumWindows(&requestMainWindowClose, processID);
|
||||
const DWORD result = WaitForSingleObject(m_hProcess, MAX_WAIT_MILLISEC);
|
||||
if (result == WAIT_TIMEOUT)
|
||||
{
|
||||
TerminateProcess(m_hProcess, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Register helper class to handle system menu items related actions. */
|
||||
virtual void register_system_menu_helper(PowertoySystemMenuIface* helper) {}
|
||||
/* Handle action on system menu item. */
|
||||
|
||||
Reference in New Issue
Block a user