Index: linux/wulfor.cc =================================================================== RCS file: /cvsroot/linuxdcpp/linuxdcpp/linux/wulfor.cc,v --- linux/wulfor.cc 8 Feb 2008 05:30:53 -0000 1.26 +++ linux/wulfor.cc 10 Feb 2008 17:25:18 -0000 @@ -28,12 +28,24 @@ #include "WulforUtil.hh" #include #include +#include void callBack(void* x, const std::string& a) { std::cout << "Loading: " << a << std::endl; } +static int(*old_x_error_handler) (Display *, XErrorEvent *); +int bad_match_xerror_handler(Display *edpy, XErrorEvent *ee) { + if(ee->error_code == BadMatch){ + cerr << "(EE) Recieved an error from X!" << endl << \ + "(EE) This is probably caused by the system tray icon, please t ry disabling it." << endl; + return 0; + } + cerr << "(EE) Fatal Xerror: request code=" << ee->request_code << ", error code=" << ee->error_code << endl; + return old_x_error_handler(edpy, ee); +} + int main(int argc, char *argv[]) { // Initialize i18n support @@ -69,6 +81,10 @@ int main(int argc, char *argv[]) WulforSettingsManager::newInstance(); WulforManager::start(); gdk_threads_enter(); + + // install our Xerror handler, save the old one for restoring + old_x_error_handler = XSetErrorHandler(bad_match_xerror_handler); + gtk_main(); gdk_threads_leave(); WulforManager::stop(); @@ -76,6 +92,10 @@ int main(int argc, char *argv[]) std::cout << "Shutting down..." << std::endl; shutdown(); + + // restore the old Xerror handler + XSetErrorHandler(old_x_error_handler); + old_x_error_handler = NULL; return 0; }