Try to fix a crash in label click handlers.

This commit is contained in:
John Preston 2021-09-13 17:38:53 +03:00
parent 8d634fc946
commit 8589a8d850

View file

@ -444,11 +444,15 @@ Text::StateResult FlatLabel::dragActionFinish(const QPoint &p, Qt::MouseButton b
_selectionType = TextSelectType::Letters; _selectionType = TextSelectType::Letters;
if (activated) { if (activated) {
const auto guard = window(); // _clickHandlerFilter may delete `this`. In that case we don't want
if (!_clickHandlerFilter // to try to show a context menu or smth like that.
|| _clickHandlerFilter(activated, button)) { crl::on_main(this, [=] {
ActivateClickHandler(guard, activated, button); const auto guard = window();
} if (!_clickHandlerFilter
|| _clickHandlerFilter(activated, button)) {
ActivateClickHandler(guard, activated, button);
}
});
} }
if (QGuiApplication::clipboard()->supportsSelection() if (QGuiApplication::clipboard()->supportsSelection()