2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fix crash in main menu swipes on macOS.

This commit is contained in:
John Preston
2025-03-17 10:45:23 +04:00
parent af35beefc2
commit fe0c1acd79
2 changed files with 23 additions and 4 deletions

View File

@@ -1012,6 +1012,19 @@ rpl::producer<OthersUnreadState> OtherAccountsUnreadState(
});
}
base::EventFilterResult MainMenu::redirectToInnerChecked(not_null<QEvent*> e) {
if (_insideEventRedirect) {
return base::EventFilterResult::Continue;
}
const auto weak = Ui::MakeWeak(this);
_insideEventRedirect = true;
QGuiApplication::sendEvent(_inner, e);
if (weak) {
_insideEventRedirect = false;
}
return base::EventFilterResult::Cancel;
}
void MainMenu::setupSwipe() {
const auto outer = _controller->widget()->body();
base::install_event_filter(this, outer, [=](not_null<QEvent*> e) {
@@ -1020,14 +1033,12 @@ void MainMenu::setupSwipe() {
|| type == QEvent::TouchUpdate
|| type == QEvent::TouchEnd
|| type == QEvent::TouchCancel) {
QGuiApplication::sendEvent(_inner, e);
return base::EventFilterResult::Cancel;
return redirectToInnerChecked(e);
} else if (type == QEvent::Wheel) {
const auto w = static_cast<QWheelEvent*>(e.get());
const auto d = Ui::ScrollDeltaF(w);
if (std::abs(d.x()) > std::abs(d.y())) {
QGuiApplication::sendEvent(_inner, e);
return base::EventFilterResult::Cancel;
return redirectToInnerChecked(e);
}
}
return base::EventFilterResult::Continue;