Fix possible crash in event loop nesting.

This commit is contained in:
John Preston 2019-09-09 10:37:22 +03:00
parent fd4f384c3b
commit b631d09a40
2 changed files with 20 additions and 17 deletions

View File

@ -534,9 +534,9 @@ void Sandbox::processPostponedCalls(int level) {
}
bool Sandbox::nativeEventFilter(
const QByteArray &eventType,
void *message,
long *result) {
const QByteArray &eventType,
void *message,
long *result) {
registerEnterFromEventLoop();
return false;
}

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/win/windows_event_filter.h"
#include "platform/win/windows_dlls.h"
#include "core/sandbox.h"
#include "mainwindow.h"
#include "main/main_session.h"
@ -55,21 +56,23 @@ bool EventFilter::nativeEventFilter(
const QByteArray &eventType,
void *message,
long *result) {
const auto msg = static_cast<MSG*>(message);
if (msg->message == WM_ENDSESSION) {
App::quit();
return Core::Sandbox::Instance().customEnterFromEventLoop([&] {
const auto msg = static_cast<MSG*>(message);
if (msg->message == WM_ENDSESSION) {
App::quit();
return false;
}
if (msg->hwnd == _window->psHwnd()
|| msg->hwnd && !_window->psHwnd()) {
return mainWindowEvent(
msg->hwnd,
msg->message,
msg->wParam,
msg->lParam,
(LRESULT*)result);
}
return false;
}
if (msg->hwnd == _window->psHwnd()
|| msg->hwnd && !_window->psHwnd()) {
return mainWindowEvent(
msg->hwnd,
msg->message,
msg->wParam,
msg->lParam,
(LRESULT*)result);
}
return false;
});
}
bool EventFilter::mainWindowEvent(