From 60da6313cf990ebf341cc688b20fd60a67f53dd2 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 9 Sep 2016 13:55:57 +0200 Subject: winrt: Fix initialization of input context f104e43a72380f66f8c517b90326a9209612106d moved QWinRTInputContext to the gui thread. However, IInputPane needs to be queried from Xaml itself. Otherwise it might cause unhandled exceptions. Change-Id: I43848c796e7ff163e6befa7c58f0ad68445b9865 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtinputcontext.cpp | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp index 968c47f2c2..63e5b0cf27 100644 --- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp @@ -86,30 +86,31 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen) { qCDebug(lcQpaInputMethods) << __FUNCTION__ << screen; - ComPtr statics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), - &statics))) { - qWarning("failed to retrieve input pane statics."); - return; - } + QEventDispatcherWinRT::runOnXamlThread([this]() { + ComPtr statics; + if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), + &statics))) { + qWarning("failed to retrieve input pane statics."); + return S_OK; + } - ComPtr inputPane; - statics->GetForCurrentView(&inputPane); - if (inputPane) { - QEventDispatcherWinRT::runOnXamlThread([this, inputPane]() { + ComPtr inputPane; + statics->GetForCurrentView(&inputPane); + if (inputPane) { EventRegistrationToken showToken, hideToken; inputPane->add_Showing(Callback( this, &QWinRTInputContext::onShowing).Get(), &showToken); inputPane->add_Hiding(Callback( this, &QWinRTInputContext::onHiding).Get(), &hideToken); - return S_OK; - }); - m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor()); - m_isInputPanelVisible = !m_keyboardRect.isEmpty(); - } else { - qWarning("failed to retrieve InputPane."); - } + m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor()); + m_isInputPanelVisible = !m_keyboardRect.isEmpty(); + } else { + qWarning("failed to retrieve InputPane."); + } + return S_OK; + }); + connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QWinRTInputContext::updateScreenCursorRect); } -- cgit v1.2.3