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



On Thu, 2007-12-06 at 11:53 +0000, Emmanuele Bassi wrote:
On Thu, 2007-12-06 at 19:40 +0800, Binary Chen wrote:
 
gdk_draw_image() forces a flush. but that is not the problem: you should
never use a while() loop inside a GTK+ application, because you are
effectively blocking the real main loop from spinning. remember: GTK+ is
not threaded.

Yes, I know GTK+ is not threaded, there is only one thread running, so
this make things more complecated, whats loop am I prohibit running?

the main loop that processes and delivers the events and handles the
redraws, and that is invoked by gtk_main(). you should read the GTK+
documentation, at this point.

Again I'd like to say in both testing the gtk_main() is not running at
all, so whats the difference? Can you point out the exact source of such
headache problem?

the exact source is, in this case, a PEBKAC; the documentation available
on how GTK+ works (at this level, at least) is quite abundant; the GTK+
tutorial should shed some more light.


use a timeout or an idle source to repaint your window with the
GdkImage.

This is just a testing program, not production code, I just want to find
out whats happening.

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 am writing a media player which need to
copy the decoded bitmap into screen.
I am using gdk_draw_image to draw a GdkImage to the drawing area.
g_timeout_add is too slow because it need to update the screen  > 20
times/sec.
So I need to use a FAST blit to screen, which is only possible using
busy while... but only if the delay is very small using usleep(1), the
result is - no things on screen.
Image a situation that a thread is doing decoding and put the result in
somewhere memory, another thread drawing to GTK+ widget.

Bin




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