From 28624d0c46ecfc19ac03ef439f123127c1cfed36 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Sat, 4 Dec 2010 15:11:56 +0100 Subject: [PATCH] qt branch: If OpenGL initialization fails, explain to the user why the program does not start. See ticket:2336 --- lib/framework/wzapp.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/framework/wzapp.cpp b/lib/framework/wzapp.cpp index 275b7d208..5fc467937 100644 --- a/lib/framework/wzapp.cpp +++ b/lib/framework/wzapp.cpp @@ -679,9 +679,7 @@ void WzMainWindow::close() int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool fullscreen) { char buf[256]; - QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); /* Workaround for incorrect text rendering on - * many platforms. - */ + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); // Workaround for incorrect text rendering on nany platforms. QApplication app(argc, argv); // Setting up OpenGL @@ -698,6 +696,11 @@ int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool full format.setSamples(fsaa); } WzMainWindow mainwindow(format); + if (!mainwindow.context()->isValid()) + { + QMessageBox::critical(NULL, "Oops!", "Warzone2100 failed to create an OpenGL context. This probably means that your graphics drivers are out of date. Try updating them!"); + return EXIT_FAILURE; + } if (fullscreen) { QDesktopWidget *desktop = qApp->desktop(); @@ -724,7 +727,7 @@ int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool full if (finalInitialization() != 0) { debug(LOG_ERROR, "Failed to carry out final initialization."); - return -1; + return EXIT_FAILURE; } debug(LOG_MAIN, "Entering main loop");