Guard against inputMethodEvent destroying the field.

This commit is contained in:
John Preston 2020-06-08 12:13:15 +04:00
parent dbcb6a35b0
commit 4ef97b57f6

View file

@ -2901,12 +2901,17 @@ void InputField::inputMethodEventInner(QInputMethodEvent *e) {
startPlaceholderAnimation(); startPlaceholderAnimation();
} }
_inputMethodCommit = e->commitString(); _inputMethodCommit = e->commitString();
const auto weak = Ui::MakeWeak(this);
_inner->QTextEdit::inputMethodEvent(e); _inner->QTextEdit::inputMethodEvent(e);
if (weak) {
const auto text = *base::take(_inputMethodCommit); const auto text = *base::take(_inputMethodCommit);
if (!processMarkdownReplaces(text)) { if (!processMarkdownReplaces(text)) {
processInstantReplaces(text); processInstantReplaces(text);
} }
} }
}
const InstantReplaces &InputField::instantReplaces() const { const InstantReplaces &InputField::instantReplaces() const {
return _mutableInstantReplaces; return _mutableInstantReplaces;