Re: segv on exit from certain uimanager program

On Fri, 2007-11-30 at 11:18 +1100, Kevin Ryde wrote:
I get a segv from the program below when using the mouse to select
File/Quit.  This is on a recent debian i386 with gtk-perl 1.161, perl
5.8.8, gtk 2.12.1 and glib 2.14.3.

  sub do_quit {
    exit 0;

bang. try replacing it with:

  sub do_quit { Gtk2->main_quit }

instead. calling "exit" is really not the nicest way to terminate a GTK+
application, in *any* language.

also, you should connect the do_quit() sub to the "destroy" signal on
the top-level you create:

  my $toplevel = Gtk2::Window->new ('toplevel');
  $toplevel->signal_connect(destroy => \&do_quit);

which has the added bonus of making it quit if the user presses the
close button added by the window manager on the window frame.

So maybe it's something subtle.  Very possibly it's unrelated to perl as
such -- I suppose in a C program nobody bothers to destroy objects when
exiting so who knows if their cleanups work!

actually, this is what everybody does in C programs as well. ;-)


Emmanuele Bassi,

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