Revision: 7199
Author:   nogu.dev
Date:     Sat Jul  9 00:48:29 2011
Log:      * qt4/immodule/quiminputcontext.cpp
  - (QUimInputContext::QUimInputContext):
    Add isStyleUpdated to initialization list.
  - (QUimInputContext::restorePreedit):
    Commit preedit when style has been updated.
  - (QUimInputContext::updateStyle):
    Set isStyleUpdated to true when style is updated.
* qt4/immodule/quiminputcontext.h
  - (QUimInputContext::isStyleUpdated): New.
http://code.google.com/p/uim/source/detail?r=7199

Modified:
 /trunk/qt4/immodule/quiminputcontext.cpp
 /trunk/qt4/immodule/quiminputcontext.h

=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp    Sat Jul  9 00:48:06 2011
+++ /trunk/qt4/immodule/quiminputcontext.cpp    Sat Jul  9 00:48:29 2011
@@ -82,7 +82,7 @@
 QUimInputContext::QUimInputContext( const char *imname )
         : candwinIsActive( false ), m_isComposing( false ), m_uc( 0 )
 #ifdef WORKAROUND_BROKEN_RESET_IN_QT4
-        , focusedWidget( 0 )
+        , focusedWidget( 0 ), isStyleUpdated( false )
 #endif
 {
 #ifdef ENABLE_DEBUG
@@ -691,14 +691,27 @@

 void QUimInputContext::restorePreedit()
 {
-    if ( m_uc )
-        uim_release_context( m_uc );
-    delete cwin;
-    m_uc = m_ucHash.take( focusedWidget );
-    psegs = psegsHash.take( focusedWidget );
-    cwin = cwinHash.take( focusedWidget );
-    if ( visibleHash.take( focusedWidget ) )
-        cwin->popup();
+    if ( isStyleUpdated ) {
+        psegs = psegsHash.take( focusedWidget );
+        QString preedit;
+        while ( !psegs.isEmpty() ) {
+            preedit += psegs.takeFirst().str;
+        }
+        commitString( preedit );
+        isStyleUpdated = false;
+
+        m_ucHash.remove( focusedWidget );
+        cwinHash.remove( focusedWidget );
+    } else {
+        if ( m_uc )
+            uim_release_context( m_uc );
+        delete cwin;
+        m_uc = m_ucHash.take( focusedWidget );
+        psegs = psegsHash.take( focusedWidget );
+        cwin = cwinHash.take( focusedWidget );
+        if ( visibleHash.take( focusedWidget ) )
+            cwin->popup();
+    }
 }
 #endif

@@ -919,6 +932,9 @@
     }
     delete cwin;
     createCandidateWindow();
+#ifdef WORKAROUND_BROKEN_RESET_IN_QT4
+    isStyleUpdated = true;
+#endif
 }

 void QUimInputContext::readIMConf()
=======================================
--- /trunk/qt4/immodule/quiminputcontext.h      Sat Jul  9 00:47:37 2011
+++ /trunk/qt4/immodule/quiminputcontext.h      Sat Jul  9 00:48:29 2011
@@ -181,6 +181,7 @@
     QHash<QWidget*, bool> visibleHash;

     QWidget *focusedWidget;
+    bool isStyleUpdated;
 #endif

     static QUimHelperManager *m_HelperManager;

Reply via email to