Check surface exists when setting textinput focus

QWaylandWindow resets the surface on various events.
Handling focus comes in a posted event, so this can be after we've
hidden a window and lost a surface.

Task-number: QTBUG-61704
Change-Id: I535ff78c6bc2b86816696a08f8eebc47186d1225
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
David Edmundson 2017-07-14 14:04:48 +01:00
parent 6a1f52c90d
commit f41bd9c06e

View File

@ -541,8 +541,10 @@ void QWaylandInputContext::setFocusObject(QObject *)
if (window && window->handle() && inputMethodAccepted()) { if (window && window->handle() && inputMethodAccepted()) {
if (mCurrentWindow.data() != window) { if (mCurrentWindow.data() != window) {
struct ::wl_surface *surface = static_cast<QWaylandWindow *>(window->handle())->object(); struct ::wl_surface *surface = static_cast<QWaylandWindow *>(window->handle())->object();
textInput()->enable(surface); if (surface) {
mCurrentWindow = window; textInput()->enable(surface);
mCurrentWindow = window;
}
} }
textInput()->updateState(Qt::ImQueryAll, QtWayland::zwp_text_input_v2::update_state_enter); textInput()->updateState(Qt::ImQueryAll, QtWayland::zwp_text_input_v2::update_state_enter);
} }