Revision: 7201
Author:   nogu.dev
Date:     Sat Jul  9 19:18:11 2011
Log:      * qt4/immodule/quiminputcontext.cpp
  - (QUimInputContext::QUimInputContext): Don't use isStyleUpdated.
  - (QUimInputContext::restorePreedit)
    * Plug leak.
    * Don't use isStyleUpdated.
  - (QUimInputContext::updateStyle):
    Set all candidate windows in cwinHash to 0 when style is updated.
* qt4/immodule/quiminputcontext.h
  - (QUimInputContext::isStyleUpdated): Remove.
http://code.google.com/p/uim/source/detail?r=7201

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

=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp    Sat Jul  9 01:54:57 2011
+++ /trunk/qt4/immodule/quiminputcontext.cpp    Sat Jul  9 19:18:11 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 ), isStyleUpdated( false )
+        , focusedWidget( 0 )
 #endif
 {
 #ifdef ENABLE_DEBUG
@@ -691,27 +691,30 @@

 void QUimInputContext::restorePreedit()
 {
-    if ( isStyleUpdated ) {
+    AbstractCandidateWindow *window = cwinHash.take( focusedWidget );
+    // if window is 0, updateStyle() was called.
+    if ( !window ) {
         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();
-    }
+
+        uim_context uc = m_ucHash.take( focusedWidget );
+        if ( uc )
+            uim_release_context( uc );
+        visibleHash.remove( focusedWidget );
+        return;
+    }
+    if ( m_uc )
+        uim_release_context( m_uc );
+    delete cwin;
+    m_uc = m_ucHash.take( focusedWidget );
+    psegs = psegsHash.take( focusedWidget );
+    cwin = window;
+    if ( visibleHash.take( focusedWidget ) )
+        cwin->popup();
 }
 #endif

@@ -933,7 +936,14 @@
     delete cwin;
     createCandidateWindow();
 #ifdef WORKAROUND_BROKEN_RESET_IN_QT4
-    isStyleUpdated = true;
+    // invalidate all the candidate windows stored in cwinHash
+    QHashIterator<QWidget*, AbstractCandidateWindow*> i( cwinHash );
+    while ( i.hasNext() ) {
+        i.next();
+        QWidget *widget = i.key();
+        delete cwinHash[ widget ];
+        cwinHash[ widget ] = 0;
+    }
 #endif
 }

=======================================
--- /trunk/qt4/immodule/quiminputcontext.h      Sat Jul  9 00:48:29 2011
+++ /trunk/qt4/immodule/quiminputcontext.h      Sat Jul  9 19:18:11 2011
@@ -181,7 +181,6 @@
     QHash<QWidget*, bool> visibleHash;

     QWidget *focusedWidget;
-    bool isStyleUpdated;
 #endif

     static QUimHelperManager *m_HelperManager;

Reply via email to