From c5eb488c3b8e7012441cadcc0b238e699c9319e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 2 Nov 2007 15:01:40 +0000 Subject: [PATCH] When KWin is run with -sync, print also backtraces for X errors. svn path=/trunk/KDE/kdebase/workspace/; revision=732021 --- main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.cpp b/main.cpp index c32512ca9b..a485b5fef5 100644 --- a/main.cpp +++ b/main.cpp @@ -57,6 +57,10 @@ Atoms* atoms; int screen_number = -1; static bool initting = false; +// Whether to run Xlib in synchronous mode and print backtraces for X errors. +// Note that you most probably need to configure cmake with "-D__KDE_HAVE_GCC_VISIBILITY=0" +// and -rdynamic in CXXFLAGS for kBacktrace() to work. +static bool kwin_sync = false; static int x11ErrorHandler(Display *d, XErrorEvent *e) @@ -84,6 +88,9 @@ int x11ErrorHandler(Display *d, XErrorEvent *e) fprintf(stderr, "kwin: %s(0x%lx): %s\n", req, e->resourceid, msg); + if( kwin_sync ) + kDebug() << kBacktrace(); + if (initting) { fputs(i18n("kwin: failure during initialization; aborting").toLocal8Bit(), stderr); @@ -140,6 +147,12 @@ int Application::crashes = 0; Application::Application( ) : KApplication( ), owner( screen_number ) { + if( KCmdLineArgs::parsedArgs( "qt" )->isSet( "sync" )) + { + kwin_sync = true; + XSynchronize( display(), True ); + kDebug() << "Running KWin in sync mode"; + } KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); KSharedConfig::Ptr config = KGlobal::config(); if (!config->isImmutable() && args->isSet("lock"))