fix X11 crash if DISPLAY is not valid
This commit is contained in:
parent
e396f8d55e
commit
3edbc00397
|
@ -212,7 +212,7 @@ if (UNIX)
|
||||||
if (HAVE_Xtst)
|
if (HAVE_Xtst)
|
||||||
|
|
||||||
# Xtxt depends on X11.
|
# Xtxt depends on X11.
|
||||||
set (HAVE_X11)
|
set (HAVE_X11 1)
|
||||||
list (APPEND libs Xtst X11)
|
list (APPEND libs Xtst X11)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -39,8 +39,10 @@ elseif (APPLE)
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
|
||||||
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||||
target_link_libraries (barrier dns_sd)
|
target_link_libraries (barrier dns_sd)
|
||||||
else()
|
endif()
|
||||||
target_link_libraries (barrier)
|
|
||||||
|
if (HAVE_X11)
|
||||||
|
target_link_libraries (barrier X11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifdef WINAPI_XWINDOWS
|
||||||
|
|
||||||
|
#include "DisplayIsValid.h"
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
bool display_is_valid()
|
||||||
|
{
|
||||||
|
auto dsp = XOpenDisplay(NULL);
|
||||||
|
if (dsp != NULL)
|
||||||
|
XCloseDisplay(dsp);
|
||||||
|
return dsp != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef WINAPI_XWINDOWS
|
||||||
|
bool display_is_valid();
|
||||||
|
#endif
|
|
@ -23,6 +23,7 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
|
#include "DisplayIsValid.h"
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
@ -54,6 +55,14 @@ bool checkMacAssistiveDevices();
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
#ifdef WINAPI_XWINDOWS
|
||||||
|
// QApplication's constructor will call a fscking abort() if
|
||||||
|
// DISPLAY is bad. Let's check it first and handle it gracefully
|
||||||
|
if (!display_is_valid()) {
|
||||||
|
fprintf(stderr, "The Barrier GUI requires a display. Quitting...\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
/* Workaround for QTBUG-40332 - "High ping when QNetworkAccessManager is instantiated" */
|
/* Workaround for QTBUG-40332 - "High ping when QNetworkAccessManager is instantiated" */
|
||||||
::setenv ("QT_BEARER_POLL_TIMEOUT", "-1", 1);
|
::setenv ("QT_BEARER_POLL_TIMEOUT", "-1", 1);
|
||||||
|
|
Loading…
Reference in New Issue