X-Git-Url: https://vaikene.ee/gitweb/highlight.css?a=blobdiff_plain;f=src%2Fmain%2FGUI%2Fmain.cpp;h=806617b22f1b5ed31b1862f684dfcac8a4eb82cf;hb=HEAD;hp=45c5043f87e7a53aa3aa802fe9a7c1ad24dbd05c;hpb=4d81227da330c21c7aa0badc88bd5ad4467067fb;p=evaf diff --git a/src/main/GUI/main.cpp b/src/main/GUI/main.cpp index 45c5043..806617b 100644 --- a/src/main/GUI/main.cpp +++ b/src/main/GUI/main.cpp @@ -3,7 +3,7 @@ * @brief The main eVaf GUI application class * @author Enar Vaikene * - * Copyright (c) 2011 Enar Vaikene + * Copyright (c) 2011-2019 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * @@ -29,9 +29,10 @@ #include #include -#include #include +#include + #include #ifdef Q_OS_LINUX @@ -81,7 +82,7 @@ static eVaf::Common::iLogger::Severity ConsoleSeverityLevel = eVaf::Common::iLog * * This function outputs messages to the console and to the log file. */ -static void messageOutput(QtMsgType type, char const * const msg) +static void messageOutput(QtMsgType type, QMessageLogContext const &, QString const & msg) { static bool inHandler = false; @@ -126,20 +127,18 @@ static void messageOutput(QtMsgType type, char const * const msg) */ static void fatalMsgHandler(QString const & msg, QString const & source, QString const & where) { + Q_UNUSED(source) + // Show the message on the screen if (BeVerbose) { if (FatalErr::message(QObject::tr("Fatal Error"), QObject::tr("%1\n\nOccurred in '%2'") .arg(msg) .arg(where), - 0) == FatalErr::Ignore) + nullptr) == FatalErr::Ignore) return; } -#ifdef Q_OS_LINUX - abort(); -#else exit(1); -#endif } } // namespace eVaf::GUI::Internal @@ -233,7 +232,7 @@ bool Application::processCommandLine(int argc, char ** argv) case Common::iLogger::Info: Internal::ConsoleSeverityLevel = Common::iLogger::Debug; break; - case Common::iLogger::Debug: + default: break; } } @@ -261,7 +260,6 @@ void Application::printHelp() " -lang[uage]=xx[_CC] Specifies the language, where xx is the ISO 639\n" " language code followed by an optional ISO 3166 country\n" " code.\n" - // Handled by the iEnv interface implementation " -root[dir]=DIR Specifies the application's root directory.\n" " -dataroot[dir]=DIR Specifies the data root directory.\n" " -etc[dir]=DIR Specifies the configuration files directory.\n" @@ -357,7 +355,7 @@ int main(int argc, char ** argv) // Install our own message handlers Common::iLogger::instance()->installFatalMsgHandler(Internal::fatalMsgHandler); - qInstallMsgHandler(Internal::messageOutput); + qInstallMessageHandler(Internal::messageOutput); // Process command-line arguments if (!Application::processCommandLine(argc, argv)) @@ -389,33 +387,39 @@ int main(int argc, char ** argv) if (!Internal::installExitHandler()) return 1; - // Plugin manager - // Plugins::PluginManager pluginManager; + int rval = 0; + { + // Plugin manager + Plugins::PluginManager pluginManager; + + // The main run loop + bool quit = false; + while (!quit) { - // The main run loop - bool quit = false; - int rval; - while (!quit) { + EVAF_INFO("%s is starting up", VER_MODULE_NAME_STR); - EVAF_INFO("%s is starting up", VER_MODULE_NAME_STR); + // Initialize the common library + if (!Common::init()) + return 1; - // Initialize the common library - if (!Common::init()) - return 1; + // Initialize the plugin manager and load plugins + if (!pluginManager.init()) + return 1; - // Initialize the plugin manager and load plugins - //if (!pluginManager.init()) - // return 1; + // Run the application + EVAF_INFO("Running %s", VER_MODULE_NAME_STR); + rval = Common::iApp::instance()->exec(); - // Run the application - rval = app.exec(); + quit = rval != Common::iApp::RC_Restart; - quit = rval != Common::iApp::RC_Restart; + EVAF_INFO("%s is %s", VER_MODULE_NAME_STR, quit ? "exiting" : "restarting"); - EVAF_INFO("%s is %s", VER_MODULE_NAME_STR, quit ? "exiting" : "restarting"); + // Unload plugins and finalize the plugin manager + pluginManager.done(); - // Unload plugins and finalize the plugin manager - // pluginManager.done(); + // Finalize the common library + Common::done(); + } } EVAF_INFO("%s exit with code %d", VER_MODULE_NAME_STR, rval);