mirror of https://github.com/procxx/kepka.git
Fix crash with event loop nesting.
This commit is contained in:
parent
a65afdac95
commit
d1be4c6d96
|
@ -390,7 +390,20 @@ void Application::refreshGlobalProxy() {
|
||||||
|
|
||||||
void Application::postponeCall(FnMut<void()> &&callable) {
|
void Application::postponeCall(FnMut<void()> &&callable) {
|
||||||
Expects(callable != nullptr);
|
Expects(callable != nullptr);
|
||||||
Expects(_eventNestingLevel > _loopNestingLevel);
|
Expects(_eventNestingLevel >= _loopNestingLevel);
|
||||||
|
|
||||||
|
// _loopNestingLevel == _eventNestingLevel means that we had a
|
||||||
|
// native event in a nesting loop that didn't get a notify() call
|
||||||
|
// after. That means we already have exited the nesting loop and
|
||||||
|
// there must not be any postponed calls with that nesting level.
|
||||||
|
if (_loopNestingLevel == _eventNestingLevel) {
|
||||||
|
Assert(_postponedCalls.empty()
|
||||||
|
|| _postponedCalls.back().loopNestingLevel < _loopNestingLevel);
|
||||||
|
Assert(!_previousLoopNestingLevels.empty());
|
||||||
|
|
||||||
|
_loopNestingLevel = _previousLoopNestingLevels.back();
|
||||||
|
_previousLoopNestingLevels.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
_postponedCalls.push_back({
|
_postponedCalls.push_back({
|
||||||
_loopNestingLevel,
|
_loopNestingLevel,
|
||||||
|
@ -430,8 +443,7 @@ bool Application::nativeEventFilter(
|
||||||
const QByteArray &eventType,
|
const QByteArray &eventType,
|
||||||
void *message,
|
void *message,
|
||||||
long *result) {
|
long *result) {
|
||||||
if (_eventNestingLevel > _loopNestingLevel
|
if (_eventNestingLevel > _loopNestingLevel) {
|
||||||
&& Platform::NativeEventNestsLoop(message)) {
|
|
||||||
_previousLoopNestingLevels.push_back(_loopNestingLevel);
|
_previousLoopNestingLevels.push_back(_loopNestingLevel);
|
||||||
_loopNestingLevel = _eventNestingLevel;
|
_loopNestingLevel = _eventNestingLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,10 +488,6 @@ void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCal
|
||||||
void OpenSystemSettingsForPermission(PermissionType type) {
|
void OpenSystemSettingsForPermission(PermissionType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeEventNestsLoop(void *message) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
|
|
|
@ -332,10 +332,6 @@ void OpenSystemSettingsForPermission(PermissionType type) {
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeEventNestsLoop(void *message) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
void psNewVersion() {
|
void psNewVersion() {
|
||||||
|
|
|
@ -35,8 +35,6 @@ PermissionStatus GetPermissionStatus(PermissionType type);
|
||||||
void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCallback);
|
void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCallback);
|
||||||
void OpenSystemSettingsForPermission(PermissionType type);
|
void OpenSystemSettingsForPermission(PermissionType type);
|
||||||
|
|
||||||
bool NativeEventNestsLoop(void *message);
|
|
||||||
|
|
||||||
QString SystemLanguage();
|
QString SystemLanguage();
|
||||||
QString SystemCountry();
|
QString SystemCountry();
|
||||||
|
|
||||||
|
|
|
@ -657,21 +657,6 @@ void OpenSystemSettingsForPermission(PermissionType type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeEventNestsLoop(void *message) {
|
|
||||||
const auto code = static_cast<const MSG*>(message)->message;
|
|
||||||
if (code > WM_NULL && code <= WM_GETMINMAXINFO) {
|
|
||||||
return true;
|
|
||||||
} else if (code >= WM_NCCREATE && code <= WM_NCXBUTTONDBLCLK) {
|
|
||||||
return true;
|
|
||||||
} else if (code == WM_WINDOWPOSCHANGING
|
|
||||||
|| code == WM_WINDOWPOSCHANGED
|
|
||||||
|| code == WM_STYLECHANGING
|
|
||||||
|| code == WM_STYLECHANGED) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
void psNewVersion() {
|
void psNewVersion() {
|
||||||
|
|
Loading…
Reference in New Issue