[kaffe] Re-used event objects (again)
Benja Fallenstein
b.fallenstein@gmx.de
Thu Jan 9 15:01:02 2003
This is a multi-part message in MIME format.
--------------050209010209070207040405
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Dalibor,
Dalibor Topic wrote:
> In the case above, I think patching kaffe would be
> better than working around bugs.
Thanks for your answer. It took me some time to figure out, but in the
end the patch was really trivial (attached). The reason was that
KeyEvt.dispatch() reused the current KeyEvt object for KEY_TYPED events
right after issuing KEY_PRESSED.
I've changed it so that it will create a new KeyEvt object. It will even
re-use a cached object if caching is activated (it's off by default, see
java.awt.Defaults.RecycleEvents).
Gzz (compiled against IBM's JDK so far) runs for me under Kaffe, now.
Success! :-)
Thank you,
- Benja
--------------050209010209070207040405
Content-Type: text/plain;
name="keyevent.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="keyevent.patch"
Index: libraries/javalib/java/awt/KeyEvt.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/KeyEvt.java,v
retrieving revision 1.6
diff -u -r1.6 KeyEvt.java
--- libraries/javalib/java/awt/KeyEvt.java 24 Jul 1999 00:56:12 -0000 1.6
+++ libraries/javalib/java/awt/KeyEvt.java 9 Jan 2003 22:52:17 -0000
@@ -39,9 +39,8 @@
if ( !consumed && !ShortcutHandler.handle( this) ) {
if ( keyChar != 0 ) { // printable key
if ( AWTEvent.keyTgt != null ) { // maybe a fast finger pulled the keyTgt under our feet
- id = KEY_TYPED;
- keyCode = 0;
- AWTEvent.keyTgt.process( this);
+ KeyEvt typedEvt = getEvent((Component)source, KEY_TYPED, 0, keyChar, modifiers);
+ AWTEvent.keyTgt.process(typedEvt);
}
}
}
--------------050209010209070207040405--