summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-16 09:40:02 -0500
committerSlávek Banko <slavek.banko@axis.cz>2013-04-16 17:34:08 +0200
commite7d0f7dba55ea0516a500110bc937938315356ea (patch)
treef8a880ff66ae6e4d3f62d1661ad75263dc9966cc
parent045b2d9ad8fbb04421db1f7c4707250bf520350a (diff)
downloadqt3-e7d0f7dba55ea0516a500110bc937938315356ea.tar.gz
qt3-e7d0f7dba55ea0516a500110bc937938315356ea.zip
Fix fatal X11 errors when both external display and command arguments are provided to QApplication
This resolves Bug 1456 (cherry picked from commit 7abfc2a181531c769d50bcb1c0bff1fc08c66de2)
-rw-r--r--src/kernel/qapplication_x11.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp
index 0f9d777..50a2bac 100644
--- a/src/kernel/qapplication_x11.cpp
+++ b/src/kernel/qapplication_x11.cpp
@@ -1790,18 +1790,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.