From 2c838dedbf617fc1e94b19c3a6316f98ac72dd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 2 Jul 2010 11:49:47 +0000 Subject: [PATCH] Added library version checks git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9768 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++- Core/Core.hh | 6 +++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Core/Core.cc b/Core/Core.cc index 306ca7dc..223a1c87 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -208,6 +208,9 @@ Core() : */ void Core::init() { + + // Check library versions + checkLibraryVersions(); // Make root_node available to the plugins ( defined in PluginFunctions.hh) PluginFunctions::setDataSeparatorNodes( dataSeparatorNode_ ); @@ -1409,9 +1412,73 @@ void Core::slotDeleteAllObjects( ){ //----------------------------------------------------------------------------- +bool Core::checkLibraryVersions() { + + bool ok = true; + bool warn = false; + + QString messages; + + QString qtCompiledVersion = QString( QT_VERSION_STR ); + QString qtCurrentVersion = qVersion(); + + if ( qtCompiledVersion != qtCurrentVersion ) { + messages += tr("QT Library Version mismatch!\n"); + + messages += tr("Currently used QT Version:\t") + qVersion(); + messages += tr("Link time QT Version:\t\t") + QString( QT_VERSION_STR ); + messages += tr("This inconsistency may lead to an unstable behaviour of OpenFLipper!"); + + warn = true; + } + + if ( !ok ) { + QString message = tr("Error! Library tests failed!\n"); + message += tr("The following problems have been found:\n\n"); + + message += messages; + + std::cerr << message.toStdString() << std::endl; + + if ( OpenFlipper::Options::gui() ) { + QMessageBox::critical ( 0, tr( "Library incompatibilities found!"),message ); + } + + // Unsafe operation, so quit the application + exit(1); + + } else if ( warn ) { + + QString message = tr("Warning! The OpenGL capabilities of your current machine/driver could be insufficient!\n\n"); + message += tr("The following checks failed:\n\n"); + message += messages; + + std::cerr << message.toStdString() << std::endl; + + if ( OpenFlipper::Options::gui() ) { + QMessageBox::warning ( 0, tr( "Library incompatibilities found!"),message ); + } + + } + #ifndef NDEBUG + else { + std::cerr << "Library Check succeeded" << std::endl; + return true; + } + #endif + + return true; +} + +//----------------------------------------------------------------------------- + bool Core::checkOpenGLCapabilities() { + // No gui->no OpenGL + if ( OpenFlipper::Options::nogui() ) + return true; + // Status ok? bool ok = true; bool warn = false; @@ -1450,7 +1517,7 @@ bool Core::checkOpenGLCapabilities() { } if ( !ok ) { - QString message = tr("Warning! The OpenGL capabilities of your current machine/driver are not sufficient!\n"); + QString message = tr("Error! The OpenGL capabilities of your current machine/driver are not sufficient!\n"); message += tr("The following checks failed:\n\n"); message += missing; message += tr("\n\nPlease update your driver or graphics card.\n"); diff --git a/Core/Core.hh b/Core/Core.hh index 08390a9d..8040b3d5 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -1115,6 +1115,12 @@ private slots: * prints an error message if not. */ bool checkOpenGLCapabilities(); + + /** \brief Checks for library inconsistencies + * + * Checks if the used libraries are consistent + */ + bool checkLibraryVersions(); private : -- GitLab