Before calling gtk_init(), save the X error handlers with XSetErrorHandler(NULL), XSetIOErrorHandler(NULL); after you're finished, restore them. Thus:
void my_plugin() { int (*old_handler) (Display *, XErrorEvent *) = XSetErrorHandler (NULL); int (*old_io_handler) (Display *, XErrorEvent *) = XSetIOErrorHandler (NULL); gtk_init (NULL, NULL); // do stuff XSetErrorHandler (old_handler); XSetIOErrorHandler (old_io_handler); } Ed On Fri, 2006-08-11 at 20:51 -0700, Kevin Arthur wrote: > To answer my own question: I solved it by calling gdk_error_trap_push() to > trap the X error. Probably not the most elegant solution but it seems to > work. > > On 8/10/06, Kevin Arthur <[EMAIL PROTECTED]> wrote: > > > > I'm having a fairly basic main loop/event problem in a GTK+ application. > > I'm sure this is a dumb beginner FAQ, but haven't had any luck finding an > > answer in the documentation. > > > > I'm on linux, using gtk-2.0, developing code that runs as a plugin within > > another program (which is not using gtk). My plugin needs to bring up a gtk > > modal dialog and then destroy it and quit the gtk loop when the user hits > > cancel or whatever. I'm apparently not exiting the gtk loop properly > > because I get an X error and crash the next time the host application > > creates a window. > > > > My main function does a gtk_init() and gtk_main(). The ok/cancel > > callbacks call gtk_widget_destroy() and gtk_main_quit(). This is based on > > example code in the API docs. > > > > The X error is > > > > BadClass, invalid event class > > (Details: serial 1337 error_code 174 request_code 149 minor_code 6) > > > > Do I need to do something to unregister for events? Should I be using > > g_main_loop() instead of gtk_main()? I've tried adding things like this > > before calling gtk_main_quit() but get the same result: > > > > > > while (gtk_events_pending()) > > gtk_main_iteration(); > > > > Thanks for any advice. > > Kevin > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list