GtkComponentPeer realization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2006-02-10 at 00:26 +0100, Mark Wielaard wrote:
> 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).

Yes, panels are never realized because they do not have an X window
associated with them.  Instead they draw on their parent's X window.  So
GtkPanelPeer should probably override isRealized to check if it has a
parent and if so, if that parent is realized.

Tom

> 
> 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



[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux