diff --git a/src/SFML/Window/Unix/Display.cpp b/src/SFML/Window/Unix/Display.cpp index 0a35ee4d7..aad1b2672 100644 --- a/src/SFML/Window/Unix/Display.cpp +++ b/src/SFML/Window/Unix/Display.cpp @@ -25,8 +25,10 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// +#include #include #include +#include namespace @@ -44,7 +46,18 @@ namespace priv Display* OpenDisplay() { if (referenceCount == 0) + { sharedDisplay = XOpenDisplay(NULL); + + // Opening display failed: The best we can do at the moment is to output a meaningful error message + // and cause an abnormal program termination + if (!sharedDisplay) + { + err() << "Failed to open X11 display; make sure the DISPLAY environment variable is set correctly" << std::endl; + std::abort(); + } + } + referenceCount++; return sharedDisplay; }