Exiting GTK main event loop from a plugin application



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



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