Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: (PR#3424) New flush code
Home

[Freeciv-Dev] Re: (PR#3424) New flush code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bursig@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3424) New flush code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Feb 2003 04:35:16 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Raimar Falke wrote:
> On Wed, Feb 26, 2003 at 12:06:13AM -0800, Jason Short wrote:
> 
>>>I think you brought this up and I now think it is a good idea: calling
>>>gui_callback_finished after each event. For this we have to break up
>>>the main loop. This is possible for:
>>> - xaw: http://www.xfree86.org/4.2.0/XtAppNextEvent.3.html
>>> - gtk: 
>>> http://developer.gnome.org/doc/API/gtk/gtk-general.html#GTK-MAIN-ITERATION
>>> - gtk2: 
>>> http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-main-iteration
>>>
>>>sdl, win32 and mui already have to loop broken up in the current
>>>source code.
>>
>>I don't understand what you're saying.  You want to break up the GUI's 
>>main event loop, replacing gtk_main() with something like
>>
>>   while (!done) {
>>     gtk_main_iteration();
>>     flush_dirty();
>>   }
>>
>>?
> 
> 
> Yes.
> 
> 
>>What if flush_dirty() itself generates a new GTK/GDK event?
> 
> 
> As it should do this only once this isn't a problem.
> 
> 
>>This is again hideously expensive
> 
> 
> Why is it expensive? You call flush_dirty, see that num_dirty_rects is
> 0 and return.
> 
> 
>>and quite error-prone.
> 
> 
> Why? I don't think so.

Because you are using the GUI in a way it was not designed to be used, 
rewriting a function that is already written and works quite well 
already.  It's just not a good idea in general to try to outwit the library.

One example is that gtk_main is re-entrant (although I doubt we use this 
feature).  If it were ever used, it would completely break the flush code.

> I think it is the cleanest solution and the one
> with the fewest possible errors.

Such a statement really needs disproving.

I submit that simply queuing a GUI event is many times "more clean" and 
has many times "fewer errors".  In the worst case this could be done 
simply by adding a timeout with a timer of 0; gtk also supports this 
type of operation via gtk_idle_add().

jason




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