[plugins/qpa] Handle case that qtvirtualkeyboard plugin is not available more gracefully
We didn't check whether creating the QPlatfromInputContext worked and accessed the m_inputContext unconditionally which obviously crashed. Now the connects related to QInputMethods are not setup if we failed to create the QPlatfromInputContext. Reviewed-By: bshah
This commit is contained in:
parent
13adf9609f
commit
5344bf1619
1 changed files with 23 additions and 21 deletions
|
@ -97,29 +97,31 @@ void Integration::initialize()
|
||||||
screenAdded(m_dummyScreen);
|
screenAdded(m_dummyScreen);
|
||||||
m_inputContext.reset(QPlatformInputContextFactory::create(QStringLiteral("qtvirtualkeyboard")));
|
m_inputContext.reset(QPlatformInputContextFactory::create(QStringLiteral("qtvirtualkeyboard")));
|
||||||
qunsetenv("QT_IM_MODULE");
|
qunsetenv("QT_IM_MODULE");
|
||||||
connect(qApp, &QGuiApplication::focusObjectChanged, this,
|
if (!m_inputContext.isNull()) {
|
||||||
[this] {
|
connect(qApp, &QGuiApplication::focusObjectChanged, this,
|
||||||
if (VirtualKeyboard::self() && qApp->focusObject() != VirtualKeyboard::self()) {
|
[this] {
|
||||||
m_inputContext->setFocusObject(VirtualKeyboard::self());
|
if (VirtualKeyboard::self() && qApp->focusObject() != VirtualKeyboard::self()) {
|
||||||
}
|
m_inputContext->setFocusObject(VirtualKeyboard::self());
|
||||||
}
|
|
||||||
);
|
|
||||||
connect(kwinApp(), &Application::workspaceCreated, this,
|
|
||||||
[this] {
|
|
||||||
if (VirtualKeyboard::self()) {
|
|
||||||
m_inputContext->setFocusObject(VirtualKeyboard::self());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
connect(qApp->inputMethod(), &QInputMethod::visibleChanged, this,
|
|
||||||
[this] {
|
|
||||||
if (qApp->inputMethod()->isVisible()) {
|
|
||||||
if (QWindow *w = VirtualKeyboard::self()->inputPanel()) {
|
|
||||||
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
connect(kwinApp(), &Application::workspaceCreated, this,
|
||||||
|
[this] {
|
||||||
|
if (VirtualKeyboard::self()) {
|
||||||
|
m_inputContext->setFocusObject(VirtualKeyboard::self());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
connect(qApp->inputMethod(), &QInputMethod::visibleChanged, this,
|
||||||
|
[this] {
|
||||||
|
if (qApp->inputMethod()->isVisible()) {
|
||||||
|
if (QWindow *w = VirtualKeyboard::self()->inputPanel()) {
|
||||||
|
QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractEventDispatcher *Integration::createEventDispatcher() const
|
QAbstractEventDispatcher *Integration::createEventDispatcher() const
|
||||||
|
|
Loading…
Reference in a new issue