--- a/qt4/immodule/quiminputcontext.cpp +++ b/qt4/immodule/quiminputcontext.cpp @@ -474,6 +474,15 @@ void QUimInputContext::reset() uim_reset_context( m_uc ); #ifdef Q_WS_X11 mCompose->reset(); + // reset() is called before setFocusWidget() is called on focus out. + // By calling commitString() before calling clearPreedit(), + // we can prevent preedit text from being removed + // when an editing widget loses focus. + // According to the Qt4 documentation on QInputContext::reset(), + // calling commitString() in reset() with a non-empty string + // will break input state consistency, but this code works on X11. + if ( m_isComposing ) + commitString( getPreeditString() ); #endif clearPreedit(); updatePreedit();