Hi, I have some patches for the QT backend.
gian paolo ciceri schrieb: > [EMAIL PROTECTED] example]$ /usr/local/kaffe-1.1.5-JIT-qt/bin/kaffe > -Xkaffe-qt-awt AnimatorApplication > java.lang.ArrayIndexOutOfBoundsException > ~ at java.awt.ComponentEvt.getEvent (ComponentEvt.java:98) > ~ at java.awt.Toolkit.evtGetNextEvent (Toolkit.java) > ~ at java.awt.EventQueue.getNextEvent (EventQueue.java:174) > ~ at java.awt.EventDispatchThread.run (EventDispatchThread.java:34) > ~ at java.lang.VMThread.run (VMThread.java:123) This happens also for me. The reasons seems to be, that the method "EventDispatcher::eventFilter" in "kaffe/libraries/clib/awt/qt/evt.cc" receive events for objects (var o) from QT, that are not registered in Kaffe's backend. (I use QT 3.3.1 with Linux and a port of QT 3.3.4 with DROPS/L4). The objects seems not to be from Kaffe, seems to be from the QT internal. Therefore, the function "getSourceIdx" returns 0xffffffff(unsigned) or -1 (signed) for these objects, therefore later "java.awt.ComponentEvt.getEvent" fails. The patch evt.diff prevents processing these events. I don't know, whether it is ok, or it is a bug of QT ? However, no outofbounds exception are thrown and the QT GUI backend works. > after a while ... > > QtAWT - Warning: QPainter: Internal error; no available GC Before this message, I get : QtAWT - Warning: QWidget (unnamed): deleted while being painted QtAWT - Warning: QPaintDevice: Cannot destroy paint device that is being painted and then QtAWT - Warning: QPainter: Internal error; no available GC QtAWT - Warning: QPainter: Internal error; no available GC ... If a QWidget is closed (Window, etc.), it seems that all QPainter objects have to be closed. If not, QT complains and later fails. The patches NativeGraphics.diff and gra.diff close the QPainter objects, created in the function "Java_java_awt_Toolkit_graInitGraphics" in "kaffe/libraries/clib/awt/qt/gra.cc". With these patches, the QT backend of Kaffe works and QT does not complain :-). Another patch is necessary for the color defines in "kaffe/libraries/clib/awt/qt/toolkit.h". If they are used with "Java_java_awt_Toolkit_graSetXORMode" in "kaffe/libraries/clib/awt/qt/gra.cc", they will produce color values > 255 and QT complains : QtAWT - Warning: QColor::setRgb: RGB parameter(s) out of range toolkit.diff solves it. Regards, Alexander Boettcher.
Index: evt.cc =================================================================== RCS file: /cvs/kaffe/kaffe/libraries/clib/awt/qt/evt.cc,v retrieving revision 1.9 diff -u -r1.9 evt.cc --- evt.cc 14 Jul 2004 07:08:10 -0000 1.9 +++ evt.cc 29 Apr 2005 09:19:43 -0000 @@ -98,7 +98,7 @@ EventPacket* packet = NULL; bool processed = false; - if(X->srcIdx == 0) + if(X->srcIdx == 0 || getSourceIdx(X, o) == 0xffffffff) return QWidget::eventFilter(o, e); switch(e->type()) {
Index: NativeGraphics.java =================================================================== RCS file: /cvs/kaffe/kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/NativeGraphics.java,v retrieving revision 1.1 diff -u -r1.1 NativeGraphics.java --- NativeGraphics.java 22 Jul 2004 19:19:32 -0000 1.1 +++ NativeGraphics.java 29 Apr 2005 10:26:57 -0000 @@ -173,6 +173,11 @@ bgClr = null; } + if ( nativeData != null ) { + Toolkit.graFreeGraphics( nativeData); + nativeData = null; + } + synchronized ( lock ) { next = cache; cache = this;
Index: gra.cc =================================================================== RCS file: /cvs/kaffe/kaffe/libraries/clib/awt/qt/gra.cc,v retrieving revision 1.5 diff -u -r1.5 gra.cc --- gra.cc 14 Jul 2004 07:08:10 -0000 1.5 +++ gra.cc 29 Apr 2005 10:20:59 -0000 @@ -68,6 +68,14 @@ memset((void*)gr, 0, sizeof(Graphics)); } + /** + * Release QPainter objects of reused NativeGraphics Java objects ! + */ + if (gr->painter != NULL) + { + delete gr->painter; + } + gr->painter = new QPainter(drw); DBG(AWT_GRA, qqDebug("painter=%x\n", gr->painter));
Index: toolkit.h =================================================================== RCS file: /cvs/kaffe/kaffe/libraries/clib/awt/qt/toolkit.h,v retrieving revision 1.5 diff -u -r1.5 toolkit.h --- toolkit.h 12 Jul 2004 10:20:53 -0000 1.5 +++ toolkit.h 29 Apr 2005 10:36:23 -0000 @@ -493,10 +493,10 @@ */ void initColorMapping ( JNIEnv* env, jclass clazz, Toolkit* X); -#define JRGB(_r,_g,_b) (_r<<16 | _g<<8 | _b) -#define JRED(_rgb) ((_rgb & 0xff0000) >> 16) -#define JGREEN(_rgb) ((_rgb & 0x00ff00) >> 8) -#define JBLUE(_rgb) (_rgb & 0x0000ff) +#define JRGB(_r,_g,_b) ((_r)<<16 | (_g)<<8 | (_b)) +#define JRED(_rgb) (((_rgb) & 0xff0000) >> 16) +#define JGREEN(_rgb) (((_rgb) & 0x00ff00) >> 8) +#define JBLUE(_rgb) ((_rgb) & 0x0000ff) /**
_______________________________________________ kaffe mailing list kaffe@kaffe.org http://kaffe.org/cgi-bin/mailman/listinfo/kaffe