mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
remove mutex
the mutex is not necessary since the global window handler is set after the WM_CREATE event is fired.
This commit is contained in:
committed by
Enrico Giordani
parent
1fc351b088
commit
25510b23e1
@@ -46,9 +46,6 @@ UINT wm_data_for_webview = 0;
|
|||||||
// - WebView confirms that the Window can close.
|
// - WebView confirms that the Window can close.
|
||||||
UINT wm_destroy_window = 0;
|
UINT wm_destroy_window = 0;
|
||||||
|
|
||||||
// Mutex for checking if the window has already been created.
|
|
||||||
std::mutex g_window_created;
|
|
||||||
|
|
||||||
// Message pipe to send/receive messages to/from the Powertoys runner.
|
// Message pipe to send/receive messages to/from the Powertoys runner.
|
||||||
TwoWayPipeMessageIPC* g_message_pipe = nullptr;
|
TwoWayPipeMessageIPC* g_message_pipe = nullptr;
|
||||||
|
|
||||||
@@ -296,7 +293,6 @@ LRESULT CALLBACK wnd_proc_static(HWND hWnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
wm_data_for_webview = RegisterWindowMessageW(L"PTSettingsCopyDataWebView");
|
wm_data_for_webview = RegisterWindowMessageW(L"PTSettingsCopyDataWebView");
|
||||||
wm_destroy_window = RegisterWindowMessageW(L"PTSettingsParentTerminated");
|
wm_destroy_window = RegisterWindowMessageW(L"PTSettingsParentTerminated");
|
||||||
g_window_created.unlock();
|
|
||||||
break;
|
break;
|
||||||
case WM_DPICHANGED:
|
case WM_DPICHANGED:
|
||||||
{
|
{
|
||||||
@@ -388,11 +384,9 @@ void wait_on_parent_process_thread(DWORD pid) {
|
|||||||
if (WaitForSingleObject(process, INFINITE) == WAIT_OBJECT_0) {
|
if (WaitForSingleObject(process, INFINITE) == WAIT_OBJECT_0) {
|
||||||
// If it's possible to detect when the PowerToys process terminates, message the main window.
|
// If it's possible to detect when the PowerToys process terminates, message the main window.
|
||||||
CloseHandle(process);
|
CloseHandle(process);
|
||||||
{
|
if (g_main_wnd) {
|
||||||
// Send a terminated message only after the window has finished initializing.
|
WINRT_VERIFY(PostMessage(g_main_wnd, wm_destroy_window, 0, 0));
|
||||||
std::unique_lock lock(g_window_created);
|
|
||||||
}
|
}
|
||||||
WINRT_VERIFY(PostMessage(g_main_wnd, wm_destroy_window, 0, 0));
|
|
||||||
} else {
|
} else {
|
||||||
CloseHandle(process);
|
CloseHandle(process);
|
||||||
}
|
}
|
||||||
@@ -431,7 +425,6 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
|
|||||||
CoInitialize(nullptr);
|
CoInitialize(nullptr);
|
||||||
|
|
||||||
g_hinst = hInstance;
|
g_hinst = hInstance;
|
||||||
g_window_created.lock(); // To be unlocked after the main window has finished being created.
|
|
||||||
initialize_message_pipe();
|
initialize_message_pipe();
|
||||||
register_classes(hInstance);
|
register_classes(hInstance);
|
||||||
g_main_wnd = create_main_window(hInstance);
|
g_main_wnd = create_main_window(hInstance);
|
||||||
|
|||||||
Reference in New Issue
Block a user