classpath
[Top][All Lists]
Advanced

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

Re: Segfault in GdkGraphics


From: Roman Kennke
Subject: Re: Segfault in GdkGraphics
Date: Sat, 24 Sep 2005 22:32:01 +0200

As things go, immediatly after sending this email I got enlightened and
found the bug. Yes it was my fault in JComponent :-) When you look at
this code (g is the component's graphics):

        Image buffer = rm.getOffscreenBuffer(this, getWidth(),
getHeight());
        Graphics g2 = buffer.getGraphics();
        g2 = getComponentGraphics(g);    // Wrong! should be ...(g2);
        g2.setClip(r.x, r.y, r.width, r.height);
        isPaintingDoubleBuffered = true;
        paint(g2);
        isPaintingDoubleBuffered = false;
        g2.dispose();

        // Paint the buffer contents on screen.
        g.drawImage(buffer, 0, 0, this);

it appears that we never draw on the buffer, dispose the component
graphics and then try to draw with this disposed graphics object. Duh...

/Roman

Am Samstag, den 24.09.2005, 22:22 +0200 schrieb Roman Kennke:
> Hi list, hi Thomas,
> 
> I am working on the Swing painting stuff in the hope to optimize it. I
> added some 'improvement' to JComponent (which is attached), which should
> enable double buffering in Swing painting, even if the paint request
> comes from the AWT side (which simply calls paint, instead of
> paintImmediatly that is called by Swing's RepaintManager).
> 
> The problem is, this hack triggers a segfault:
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1395782736 (LWP 8688)]
> 0xae43e6b0 in Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative (
>     env=0x805f234, obj=0xafe83938, x=-5, y=-5)
>     at gnu_java_awt_peer_gtk_GdkGraphics.c:281
> 281       g->x_offset += x;
> (gdb)
> 
> I really don't see why my JComponent hack could cause g to be NULL. I am
> not doing something illegal in JComponent, do I?
> 
> BTW: You might think that my 'stunt act' in JComponent looks a little
> weird. Meditate a little over it. The reason I do it this way and not
> like it has been for some time is to provide more compatibility between
> AWT and Swing, so that Swing components can be used inside an AWT tree
> (and not only JRootPanes, like it has been before). I think this hack
> should work as it is.
> 
> Any ideas on the segfault?
> 
> /Roman
> 
> _______________________________________________
> Classpath mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/classpath

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]