Hi Tom, On Thu, 2006-02-09 at 09:53 -0500, Thomas Fitzsimmons wrote: > On Thu, 2006-02-09 at 13:52 +0100, Mark Wielaard wrote: > > I like to debug this a bit further, but I couldn't find good > > documentation on the handling of (un)realized GtkComponentPeers. Does > > anybody have a link or an explanation of whether or not the above should > > ever happen? > > Yes it can happen especially in multi-threaded applications. You're > probably right to just ignore the paint event. It'd be useful to know > if hsqldb makes calls into the peers from different threads. For > example if it shows a window in one thread and another thread handles > painting on that window.
No it doesn't. I was finally able to extract a simple testcase that
shows the problem which also doesn't use any extra application Threads.
See attached. If you update the tree to include Lillian's latest patches
for GtkPanelPeer (which made the logic more clear to me, thanks Lillian)
and add the following hack, you can see that the Panel doesn't seem to
get realized. And always will print out the following after clicking on
the button:
getGraphics() called on unrealized:
java.awt.Panel[panel0,4,25,66x25,invalid,parent=frame0,layout=java.awt.FlowLayout]
I am not sure how/where the GtkPanelPeer should have been realized
and/or whether this comes from the "delayed realization" you talked
about (I don't actually see where this Panel will ever get realized to
be honest).
The Hack (or workaround, if you only put in the return null, and not the
dumpStack):
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java 9 Feb 2006 17:44:30 -0000
1.101
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 9 Feb 2006 23:14:19 -0000
@@ -263,6 +262,13 @@
public Graphics getGraphics ()
{
+ if (! isRealized())
+ {
+ System.err.println("getGraphics() called on unrealized: " + awtWidget);
+ Thread.dumpStack();
+ return null;
+ }
+
if (GtkToolkit.useGraphics2D ())
return new GdkGraphics2D (this);
else
Any insights on how to properly debug this welcome.
I do have one patch to make the event passing a bit simpler. That
doesn't change the result of this test case, but it makes it a little
easier to follow the events that are fired. I'll post it in a second to
the patches list.
Cheers,
Mark
import java.awt.*;
import java.awt.event.*;
public class PanelPanel extends Frame implements ActionListener
{
public static void main(String[] args)
{
new PanelPanel();
}
PanelPanel()
{
Button b = new Button("Click me!");
b.addActionListener(this);
add(b);
pack();
show();
}
public void actionPerformed(ActionEvent ae)
{
Panel p = new Panel();
p.setBounds(new Rectangle(20, 20));
removeAll();
add(p);
doLayout();
p.repaint();
}
}
signature.asc
Description: This is a digitally signed message part

