From 4cd263f28503c1db03b7e9a4f1302589b473d4d8 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Thu, 21 Jul 2016 13:42:09 +0200 Subject: [PATCH] Make sure FlightGear is initialized before using the PUI dialog box, dump the the console otherwsise --- src/GUI/MessageBox.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/GUI/MessageBox.cxx b/src/GUI/MessageBox.cxx index 856e15a27..846752af8 100644 --- a/src/GUI/MessageBox.cxx +++ b/src/GUI/MessageBox.cxx @@ -6,6 +6,7 @@ #include "MessageBox.hxx" +#include
#include
#include #include @@ -132,12 +133,15 @@ MessageBoxResult modalMessageBox(const std::string& caption, if (!moreText.empty()) { s += "\n( " + moreText + ")"; } -// SG_LOG(SG_GENERAL, SG_ALERT, s); - NewGUI* _gui = (NewGUI *)globals->get_subsystem("gui"); - SGPropertyNode_ptr dlg = _gui->getDialogProperties("popup"); - dlg->setStringValue("text/label", s ); - _gui->showDialog("popup"); + if (fgGetBool("/sim/initialized", false) == false) { + SG_LOG(SG_GENERAL, SG_ALERT, s); + } else { + NewGUI* _gui = (NewGUI *)globals->get_subsystem("gui"); + SGPropertyNode_ptr dlg = _gui->getDialogProperties("popup"); + dlg->setStringValue("text/label", s ); + _gui->showDialog("popup"); + } return MSG_BOX_OK; #endif } @@ -153,11 +157,18 @@ MessageBoxResult fatalMessageBox(const std::string& caption, #elif defined(HAVE_QT) return QtMessageBox(caption, msg, moreText, true); #else - std::cerr << "FATAL:" << msg << "\n"; + std::string s = "FATAL: "+ msg; if (!moreText.empty()) { - std::cerr << "(" << moreText << ")"; + s += "\n( " + moreText + ")"; + } + if (fgGetBool("/sim/initialized", false) == false) { + std::cerr << s << std::endl; + } else { + NewGUI* _gui = (NewGUI *)globals->get_subsystem("gui"); + SGPropertyNode_ptr dlg = _gui->getDialogProperties("popup"); + dlg->setStringValue("text/label", s ); + _gui->showDialog("popup"); } - std::cerr << std::endl; return MSG_BOX_OK; #endif } -- 2.39.5