From 7abfc2a181531c769d50bcb1c0bff1fc08c66de2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 16 Apr 2013 09:40:02 -0500 Subject: Fix fatal X11 errors when both external display and command arguments are provided to QApplication This resolves Bug 1456 --- src/kernel/qapplication_x11.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 121d633..eba573b 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -1803,18 +1803,26 @@ void qt_init_internal( int *argcptr, char **argv, } } #endif - // Connect to X server - - if( qt_is_gui_used ) { - if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) { - qWarning( "%s: cannot connect to X server %s", appName, - XDisplayName(appDpyName) ); - qApp = 0; - exit( 1 ); - } + if ( display ) { + // Display connection already opened by another application - if ( appSync ) // if "-sync" argument - XSynchronize( appDpy, TRUE ); + appForeignDpy = TRUE; + appDpy = display; + } + else { + // Connect to X server + + if( qt_is_gui_used ) { + if ( ( appDpy = XOpenDisplay(appDpyName) ) == 0 ) { + qWarning( "%s: cannot connect to X server %s", appName, + XDisplayName(appDpyName) ); + qApp = 0; + exit( 1 ); + } + + if ( appSync ) // if "-sync" argument + XSynchronize( appDpy, TRUE ); + } } } // Common code, regardless of whether display is foreign. -- cgit v1.2.1