From 4ef97b57f6925ac9f1e3221676f49dffb4fe8c19 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 8 Jun 2020 12:13:15 +0400 Subject: [PATCH] Guard against inputMethodEvent destroying the field. --- ui/widgets/input_fields.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/widgets/input_fields.cpp b/ui/widgets/input_fields.cpp index 23abd56..c435025 100644 --- a/ui/widgets/input_fields.cpp +++ b/ui/widgets/input_fields.cpp @@ -2901,10 +2901,15 @@ void InputField::inputMethodEventInner(QInputMethodEvent *e) { startPlaceholderAnimation(); } _inputMethodCommit = e->commitString(); + + const auto weak = Ui::MakeWeak(this); _inner->QTextEdit::inputMethodEvent(e); - const auto text = *base::take(_inputMethodCommit); - if (!processMarkdownReplaces(text)) { - processInstantReplaces(text); + + if (weak) { + const auto text = *base::take(_inputMethodCommit); + if (!processMarkdownReplaces(text)) { + processInstantReplaces(text); + } } }