Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54627

Qt custom input plugin crashes when using Input methods

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.6
    • 5.5.1
    • QPA: Windows
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            qbprog Thomas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes