0

I'm creating a gtk app like this:

Glib::RefPtr<Gtk::Application> app;
try {
    app = Gtk::Application::create(argc, argv, "loocal.testgtk",
        Gio::APPLICATION_HANDLES_COMMAND_LINE);
}
catch (...) {
    ....
}

If the X server isn't there (isn't reachable) the process is aborted, the catch(...) part is never executed.

Q: Is there a way prevent abort and to catch this exception - and e.g. retry or connect to a fall-back display?

Also: Is there a way to catch the exception when the connection with the X server breaks - in order to (try to) restart the GUI part of the application and reconnect to the X server or to a fall-back X server?

Zrin
  • 919
  • 15
  • 25

1 Answers1

2

The default is to simply call exit(1) if the display cannot be opened.

If you want to override this, do the following before anything else. Call gtk_init_check(), then gdk_display_open() and gdk_display_manager_set_default_display().

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243