Bug 24674 - Trying to use gcj and AWT qt-peers to show applets in Konqueror hits assert()
Summary: Trying to use gcj and AWT qt-peers to show applets in Konqueror hits assert()
Status: ASSIGNED
Alias: None
Product: classpath
Classification: Unclassified
Component: awt (show other bugs)
Version: 0.18
: P3 normal
Target Milestone: ---
Assignee: Sven de Marothy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-04 14:46 UTC by bero
Modified: 2006-08-04 16:59 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-11-04 22:07:25


Attachments
Fix (324 bytes, patch)
2005-11-04 14:50 UTC, bero
Details | Diff
Small test case triggering the problem (254 bytes, text/x-java)
2006-08-04 16:59 UTC, bero
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bero 2005-11-04 14:46:04 UTC
Trying to use gij (4.1 SVN - uses classpath 0.18) and AWT qt-peers to show applets in Konqueror 3.5 hits an assert() causing gij to terminate.
Comment 1 bero 2005-11-04 14:50:22 UTC
Created attachment 10144 [details]
Fix

Attaching a fix -- not 100% sure this is the right thing to do though (I don't speak Java/JNI well enough to figure out why this is called without a QWidget, but in terms of normal C++ Qt this should get you the application default palette, which is what the patch does...).
Comment 2 Sven de Marothy 2005-11-07 09:39:06 UTC
You're right. This isn't meant to happen (hence the assert()!). The function in question (getting the native bg color) is one of the QtComponentPeer.setup() calls, all of which are supposed to be performed *after* the widget has been created in the init() method. So the question here is: Why hadn't the init() method created a widget?

It'd be quite helpful if you could say which component-peer causes this? (and thus has the failing init()).
Comment 3 bero 2005-12-18 22:53:33 UTC
Sorry for the delay, bug 24698 prevented me from doing any further testing lately (using the workaround attached to bug 24698 now -- not perfect, but sufficient to tell konqueror to use gij with qt peers again).

With this new compiler and the patch attached to this bug, I'm now getting:

QFont: It is not safe to use text and fonts outside the gui thread
[... repeated over and over ...]
java: ../../../../../../../libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp:257: void Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround(JNIEnv*, __jobject*, jint, jint, jint, jboolean): Assertion `widget' failed.


I'll add some debug statements to try and figure out what's going on now.
Comment 4 bero 2006-05-27 16:21:07 UTC
This is weird stuff...
I've added some debug info to Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround:

JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround
(JNIEnv *env, jobject obj, jint r, jint g, jint b, jboolean isForeground)
{
  QColor *color = new QColor(r, g, b);

  QWidget *widget = (QWidget *) getNativeObject( env, obj );
  if(!widget) {
          jclass cls = env->GetObjectClass( obj );
          if(!cls) {
                  cerr << "QtComponentPeer_setGround called without object!" << endl;
                  return;
          }
          jmethodID method = env->GetMethodID(cls, "getName", "()Ljava/lang/String");
          jstring name = (jstring) env->CallObjectMethod(cls, method);
          char const *n=env->GetStringUTFChars(name, 0);
          cerr << "QtComponentPeer_setGround called on a " << n << endl;
          env->ReleaseStringUTFChars(name, n);
          return;
  }
  mainThread->postEventToMain( new AWTBackgroundEvent(widget,
                                                      (isForeground == JNI_TRUE),
                                                      color) );
}


This results in "QtComponentPeer_setGround called on a "
Comment 5 bero 2006-08-04 16:59:14 UTC
Created attachment 12018 [details]
Small test case triggering the problem

I've finally managed to create a smaller test case than Konqueror that hits the assertion -- seems to be in some way related to java Canvas-es.

Running the test case results in:
QFont: It is not safe to use text and fonts outside the GUI thread
[repeated numerous times]
java: ../../../../../../../libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp:257: void Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround(JNIEnv*, __jobject*, jint, jint, jint, jboolean): Assertion `widget' failed.
Aborted