ibus: check object validity before honoring inputMethodAccepted()

`inputMethodAccepted()` always return false if there is no current focus
object. This means QIBusPlatformInputContext will fail to send the
necessary `FocusOut` request to the input context, causing IBus to not
send the appropriate content type information to the panel service when
the application regains focus and issue a `FocusIn` request.

This results in issues like
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5346, which can
happen when a Qt application is in foreground as the IBus daemon fails
to propagate the content type information to GNOME Shell, which acts as
the panel service on GNOME systems.

Fix this by checking for the validity of `object` before honoring the
result of `inputMethodAccepted()`.

Change-Id: I6b79ffc7c5f03ffc05527c29e52a0859f3594bfa
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 95b4cfb1af9aefe3ff3aa151804f464388329c63)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Phan Quang Minh 2022-10-07 13:52:38 +07:00 committed by Qt Cherry-pick Bot
parent ec5370458f
commit c9837c84aa

View File

@ -236,7 +236,7 @@ void QIBusPlatformInputContext::setFocusObject(QObject *object)
// It would seem natural here to call FocusOut() on the input method if we
// transition from an IME accepted focus object to one that does not accept it.
// Mysteriously however that is not sufficient to fix bug QTBUG-63066.
if (!inputMethodAccepted())
if (object && !inputMethodAccepted())
return;
if (debug)