Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
5.5.1
-
None
-
Windows 10
-
47ff3dcd087c1239e885439963f02bb8b53b19ed (qtbase/5.6)
Description
When using a custom input method plugin which provides a custom QPlatformInputContext , the application crashes when inserting chinese characters which require "composition".
The issue is that our class derives from QPlatformInputContext , while the QWindowsContext requires and uses a class which derives by QWindowsInputContext (only) when handling
InputMethodStartCompositionEvent,InputMethodCompositionEvent, InputMethodEndCompositionEvent,InputMethodOpenCandidateWindowEvent,InputMethodCloseCandidateWindowEvent,InputMethodRequest
the culprit is the static_cast in
static inline QWindowsInputContext *windowsInputContext() { return qobject_cast<QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext()); }
which is wrong when the input context plugin is customized and is not deriving from the class (in our case to provide a virtual keyboard).
Indeed, the compositions method work only without any custom plugin:
void QWindowsIntegration::initialize() { if (QPlatformInputContext *pluginContext = QPlatformInputContextFactory::create()) d->m_inputContext.reset(pluginContext); else d->m_inputContext.reset(new QWindowsInputContext); }
A solution would be deriving our custom input context from QWindowsInputContext but, it's not possible to derive from QWindowsInputContext because it's private and not exported.
This happens only with composition events, all the other are handled correctly (ie. don't require the specific windows class)
The steps to reproduce are simple:
- Load a custom input context plugin (like a virtual keyboard), make sure it is enabled
- Add in Windows the Chinese Input Language and activate it
- Enter in any QLineEdit any chinese character which requires composition