[immodule-qt] Re: [SCIM] scim-qtimm 0.7 released

Kazuki Ohta mover at hct.zaq.ne.jp
Mon Sep 6 09:39:23 EEST 2004


Hi, Cougar.

More refactored version is here.
This code is based on the code of QApplication::notify.
I think this code is more cleaner.

void QApplication::postIMEvent( QObject *receiver, QIMEvent *event )
{
    if( event->type() == QEvent::IMCompose )
        postEvent( receiver, event );
    else {
        if (receiver->postedEvents) {
            //get rid of IMCompose event posted before
            QPostEventList * l = receiver->postedEvents;
            QPostEvent * pe;
            l->first();
            while( ( pe = l->current()) != 0 ) {
                if ( pe->event && pe->receiver == receiver &&
                    pe->event->type() == QEvent::IMCompose ) {
                    pe->event->posted = FALSE;
                    delete pe->event;
                    pe->event = 0;
                    l->remove();
                    continue;
                }
                l->next();
            }
            sendEvent( receiver, event );
            delete event;
        }
    }
}

On Monday 06 September 2004 12:34, LiuCougar wrote:
> On Mon, 6 Sep 2004 11:27:26 +0800, Zhe Su <james.su at gmail.com> wrote:
> > Hi,
> >   I just read though this new code, and found that there is no exit
> > point in the for (;;) {...} loop. Is it correct?
>
> Oops, sorry about that, the rectified version is:
> void QApplication::postIMEvent( QObject *receiver, QIMEvent *event )
> {
>     if( event->type() == QEvent::IMCompose )
>         postEvent( receiver, event );
>     else {
>         QPostEventList * l = receiver->postedEvents;
>
>         //get rid of IMCompose event posted before
>         if ( event->type() == QEvent::IMCompose ) {
>             l->first();
>             QPostEvent * cur = 0;
>             for ( ;; ) {
>                 while ( (cur=l->current()) != 0 &&
>                         ( cur->receiver != receiver ||
>                           cur->event == 0 ||
>                           cur->event->type() != event->type() ) )
>                     l->next();
>                 if ( l->current() != 0 ) {
>                     if ( cur->event->type() == QEvent::IMCompose ) {
>                         delete cur->event;
>                         l->remove(cur);
>                     }
>                 } else
>                   break;
>             }
>         }
>         sendEvent( receiver, event );
>         delete event;
>     }
> }
>
> Thanks for correcting me ;)
>
> Regards,

-- 
---------------------------------
Move the worl:D!
Kazuki Ohta : mover at hct.zaq.ne.jp



More information about the immodule-qt mailing list