한창길 wrote:
> Abdelrazak Younes wrote:
> 
>> OK, I got it. But I think this is not the place to take care of
>> that. At this level, there should be only one (or two in case of
>> surrogate) utf16 character. I think that the proper place to trim
>> those superfluous characters is in
>> 'GuiWorkArea::inputMethodEvent()'. Could you please have a look at
>> this method? I guess we don't do all that is required to properly
>> handle the input method.
> 
>> Out of curiosity, could you please give me the debug output of "lyx
>> -dbg key" in order to see what is the value of the second
>> character?
> 
> OK, here's the typical debug message which leads the crash,
> 
> "virtual void
> lyx::frontend::GuiWorkArea::inputMethodEvent(QInputMethodEvent*)
> preeditString = commitString  =ふじださふ virtual void
> lyx::frontend::GuiWorkArea::keyPressEvent(QKeyEvent*) count=1 text=ふじ
> ださふ isAutoRepeat=0 key=0 Setting key to 0, ふじださふ KeySym is ふじださふ isOK
> is 1 isMod is 0 text.size=5 Assertion triggered in virtual
> lyx::char_type lyx::QLyXKeySym::getUCSEncoded() const by failing
> check "text_.size() <= 2" in file QLyXKeySym.C:d4  ""
> 
> As you see, my input method can send any number of "text.size"
> characters at once.   So coding with "text.size"  seems dangerous as
> far as CJK languages are concerned.

OK, then Georg is right about generating as many keypressEvent as there
are characters in the inputMethodEvent. Please apply this patch and try
again.

I think we should have an RC setting for inputMethodEvent. This should
be enabled only for Asian language (see patch).

Abdel.
Index: GuiWorkArea.C
===================================================================
--- GuiWorkArea.C       (revision 17121)
+++ GuiWorkArea.C       (working copy)
@@ -205,6 +205,8 @@
 
        // Enables input methods for asian languages.
        // Must be set when creating custom text editing widgets.
+       // FIXME: we need an RC settings for that:
+       // setAttribute(Qt::WA_InputMethodEnabled, lyxrc.input_method_enabled);
        setAttribute(Qt::WA_InputMethodEnabled, true);
 }
 
@@ -581,8 +583,10 @@
                        key = Qt::Key_AsciiCircum;
                // FIXME: Needs for investigation, this key is not really used,
                // the ctor below just check if key is different from 0.
-               QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier, text);
-               keyPressEvent(&ev);
+               for (int i = 0; i < text.size(); ++i) {
+                       QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier, 
text[i]);
+                       keyPressEvent(&ev);
+               }
        }
        e->accept();
 }

Reply via email to