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




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.

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]