platforminputcontexts: future-proof compose plugin

If this plugin is loaded at some later point during application
run-time, the focus object might be nullptr. We can avoid that by
using qApp->focusObject(), when m_focusObject==nullptr;

Task-number: QTBUG-74465
Change-Id: I0d82410ed557ea1a8fde28a1807f790854951cda
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Gatis Paeglis 2019-03-15 11:56:01 +01:00
parent 902ae438aa
commit d6e65ecac5

View File

@ -40,6 +40,7 @@
#include <QtCore/QCoreApplication>
#include <QtGui/QKeyEvent>
#include <QtGui/QGuiApplication>
#include <locale.h>
@ -121,7 +122,14 @@ bool QComposeInputContext::filterEvent(const QEvent *event)
QInputMethodEvent event;
event.setCommitString(composedText);
QCoreApplication::sendEvent(m_focusObject, &event);
if (!m_focusObject && qApp)
m_focusObject = qApp->focusObject();
if (m_focusObject)
QCoreApplication::sendEvent(m_focusObject, &event);
else
qCWarning(lcXkbCompose, "no focus object");
reset();
return true;