Skip to content

Commit

Permalink
Fixed memory management issue while closing native Win32 window (#1126)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicorac committed Jul 14, 2023
1 parent dc417e9 commit 6029bcd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/webview/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,10 +1336,25 @@ class win32_edge_engine {
}
void *window() { return (void *)m_window; }
void terminate(int exitCode = 0) {

// event to wait for window close completion
auto evtWindowClosed = CreateEvent(
NULL, // default security attributes
TRUE, // manual-reset event
FALSE, // initial state is nonsignaled
TEXT("WindowClosedEvent") // object name
);
processExitCode = exitCode;

dispatch([=]() {
DestroyWindow(m_window);
SetEvent(evtWindowClosed);
});

// wait for dispatch() to complete
WaitForSingleObject(evtWindowClosed, 10000);

This comment has been minimized.

Copy link
@Spishous

Spishous Apr 5, 2024

#1179
I think it's this line that causes a delay in closing the window when "exitProcessOnClose" is true.
The delay corresponds exactly to the 10sec indicated. But I don't know enough C++ to change something.

CloseHandle(evtWindowClosed);

}
void dispatch(dispatch_fn_t f) {
PostThreadMessage(m_main_thread, WM_APP, 0, (LPARAM) new dispatch_fn_t(f));
Expand Down

0 comments on commit 6029bcd

Please sign in to comment.