From: Vadim Zeitlin Date: Tue, 3 May 2011 10:40:31 +0000 (+0000) Subject: Don't crash on startup of console programs in monolithic wxX11 build. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f18b415ee35de1ca1725f0fe1fa70589be9dcfeb Don't crash on startup of console programs in monolithic wxX11 build. When using monolithic build, GUI-specific wxWinModule is still linked in but its initialization crashes because there is no global display. Simply don't do anything in this module OnInit() in this case to avoid the problem (which affected e.g. wxrc in this build configuration). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 3b569bf98f..c52af30a53 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -1747,6 +1747,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule) bool wxWinModule::OnInit() { Display *xdisplay = wxGlobalDisplay(); + if ( !xdisplay ) + { + // This module may be linked into a console program when using + // monolithic library and in this case it's perfectly normal not to + // have a display, so just return without doing anything and avoid + // crashing below. + return true; + } + int xscreen = DefaultScreen( xdisplay ); Window xroot = RootWindow( xdisplay, xscreen ); g_eraseGC = XCreateGC( xdisplay, xroot, 0, NULL );