Re: I can't understand the difference output of only a line differ



again: no need to reply to me directly.

On Thu, 2007-12-06 at 20:29 +0800, Binary Chen wrote:

 
what's happening is that you are blocking the main loop from ever
running, so any result you see is an undefined behaviour.

for the third time: use a timeout/idle source instead of the while()
loop to hook into the GTK+ main loop.

You don't know my situation.

I read your other emails in this thread and I can say I understood
fairly well your situation; and yet, you don't seem to understand what
I'm saying to you: what are you doing leads to undefined behaviours, so
*don't do it*.

I am using gdk_draw_image to draw a GdkImage to the drawing area.

why are you using a GdkImage in the first place? can't you just use a
client-side pixbuf and then blit it to the target widget using
gdk_draw_pixbuf() instead?

anyway:

g_timeout_add is too slow because it need to update the screen  > 20
times/sec.

20 times per sec is 50 msecs, which is fairly doable for a timeout
source; you might want to disable the double buffering and set the
widget you're drawing on as paintable, to squeeze it every millisecond.

in any case, instead of using a timeout you can use an idle source with
g_idle_add_full(), and setting a fairly high priority (but probably
lower than GDK_PRIORITY_REDRAW to avoid useless tearing).

So I need to use a FAST blit to screen, which is only possible using
busy while...

there already is a busy loop: it's the GTK+ main loop. you can hook into
it, but you cannot avoid calling it because (and this is the central
bit) it leads to undefined behaviours like you witnessed.

aside from this, I cannot stress enough that it seems to me you don't
know GTK+ (let alone GDK) well enough. so my recommendation is for you
to spend some time learning and getting acquainted with how GTK+ works
first.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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