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:
parent
902ae438aa
commit
d6e65ecac5
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user