Re: [gtkmm] Catching Exceptions



> >argh!
> >
> >i thought this was finally fixed ?
> >there is no reason why Kit::~Kit may call exit().
> >
> >it is my own duty to return from main.
> >maybe i want to do something else after using gtk-- ?
> >gtk-- is just a library. it has no right to play god.
> 
> I agree absolutely. The problem, however, is that this exists down at
> the GTK level, not the Gtk-- one. AFAIK, there isn't any way to tell
> GTK "ok, shutdown and cleanup" that is guaranteed to be clean without
> also telling it to call exit(0).
> 
> Here's what the (fantastic) GTK reference manual says:
> 
[...]
> 
> No other listed function is described as shutting down the GUI.
> 
> Now, in reality, we know that something like:
> 
>      while (gtk_main_level()) {
>           gtk_main_quit(); 
>      }
> 
> will accomplish most of the desired goal *currently*. But given the
> public description of gtk_exit(), there is nothing to stop some
> critical functionality from moving into that function at some point.

Actually it is worse.  Gtk+ is is very bad about being greedy with resources.
THus every time it allocates a piece of memory of certain size, it never
frees it.  It just holds that chunk in researve in case another thing
the same size needs it.  I tried in vain at one point to convince them
to switch to an allocator which frees if the number of items on the
stack grows larger than 32 or 64.  (Which according to analysis slows
gtk+ programs by 0.01%.)  But they really won't hear of it.  
Thus the only way gtk+ will ever free is by exiting!

> 
> So, I feel that until GTK advertises another function that *just*
> shuts down the GUI and frees all resources, Gtk::Main (I *hate* the
> word "Kit" :) should continue to call gtk_exit().

(Okay, I secretly hate Main because someone sent this code which
scares me. 
int main(int argc, char** argv) 
     { Gtk::Main main(argc,argv);
)


> 
> OTOH, I really feel that GTK should offer such a function. But then
> again, this is not easy to do with 100% correction. Shutting down the
> connection to the X server would work for me, though, and if there was
> a way to force GDK and GTK to destroy every object as well, that would
> be even better. Not glib though, since a program may be using glib for
> other things.

Well, we could place some code to do it, but it would be our own mess.
If you send destroy to every toplevel widget, you will blast everything
but those memory lists.    I suspect the only way it will
happen is if someone gets gtk+ patch in.  But considering my tim
is down to just basic gtk-- maintainence it won't be me.

--Karl




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