From: Tom F. <tcf...@mt...> - 2003-07-28 18:37:12
|
On Monday 28 July 2003 8:21 am, Masao Mutoh wrote: > IMO, > Sometimes it's not good idea to raise Exception in this kind of block. > Because, the exceptions raise to Gtk.main always. And Gtk.main can be > nested. And if you quit block with exception, the GLib objects leak memory. > #It's the reason why we didn't raise exception in the block. > > So in that case, it may be better to exit in that handler. OK. > require 'gtk2' > Gtk.init > Gdk.set_x_io_error_handler do |display, errno, error| > puts "Disconnected from X server #{display}, (Error #{errno}, #{error})" > exit(1) > end > > Gtk::Window.new.show > Gtk.main To Zacharia, the above should work. You'll need to get the new version from CVS. When the X server dies, the x_io_error_handler block is called. (You can test this by using xkill). You can save information in that function, but don't call gdk functions or throw exceptions. And naturally this won't do anything if the power dies, so it might be a good idea to save your info in a timeout function also. -- Tom Felker The whole point of communication is sharing information. |