From: Olivier Andrieu MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: <17773.54865.833705.129071 at karryall.dnsalias.org> Date: Wed, 29 Nov 2006 19:49:53 +0100 To: Maxence Guesdon Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: strange behaviour of GMain.Main.main / GMain.Main.quit In-Reply-To: <20061129150731.3660ab96 at tintin.inria.fr> References: <20061129150731.3660ab96 at tintin.inria.fr> Content-Type: text/plain; charset=us-ascii Content-Length: 1095 Salut Maxence, Maxence Guesdon [Wednesday 29 November 2006] : > > Hello, > > I'm experiencing problems while using GMain.Main.main and GMain.Main.quit. > Here is a program to reproduce the problem. It creates a window. > When "Return" is pressed, the nb_waits counter in incrementend, then > GMain.Main.main is called to wait for a GMain.Main.quit, then "pop!" is > displayed (that is, when GMain.Main.main returns). > When "Escape" is pressed, GMain.Main.quit is called nb_waits times. > I thought that then all waiting "pop!" would be displayed one after the > other but it works only when there is only one GMain.Main.main waiting. > Is this a bug or a feature ? It's not a bug, that's just how the glib event loop API works. A GMainLoop has a is_running boolean flag. g_main_loop_run basically does a: while (loop->is_running) process_events (loop); and g_main_loop_quit simply sets loop->is_running to FALSE. To get this multiple level of loops, you'd need to create a new loop object or something (but lablgtk doesn't wrap all the necessary functions). -- Olivier