Re: [gtkmm] Catching Exceptions



[ GTK folk: gtkmm-main folk are discussing whether our main loop
  object (Gtk::Kit aka Gtk::Main) should call gtk_exit() itself
]

>> > But, just moving the "throw 1;" line to the other side of "Gtk::Kit
>> > kit(argc, argv)" returns "0" without printing the error message:
>> 
>> Gtk::Kit::~Kit calls gtk_exit(0), so the program terminates during the
>> stack unwinding.
>
>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:

---------------------------------------------------------------------
gtk_exit ()

  void        gtk_exit                        (gint error_code);

Terminate the program and return the given exit code to the
caller. This function will shut down the GUI and free all resources
allocated for 

   error_code :
      Return value to pass to the caller. This is dependend on the
      target system but at least on Unix systems 0 means success.
---------------------------------------------------------------------

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.

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().

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.

--p






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