diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 10376dcfaca601a305ff3bbb925b62895737e1cd..3dbc13fd5df709d5995014c75fc96d218e8d9bfa 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -49,6 +49,7 @@ int Msg::_progressMeterCurrent = 0; std::map<std::string, double> Msg::_timers; int Msg::_warningCount = 0; int Msg::_errorCount = 0; +std::string Msg::_firstWarning; std::string Msg::_firstError; GmshMessage *Msg::_callback = 0; std::string Msg::_commandLine; @@ -307,6 +308,8 @@ void Msg::Warning(const char *fmt, ...) FlGui::instance()->check(); std::string tmp = std::string("@C5@.") + "Warning : " + str; FlGui::instance()->addMessage(tmp.c_str()); + if(_firstWarning.empty()) _firstWarning = str; + FlGui::instance()->setLastStatus(); } #endif @@ -521,11 +524,9 @@ void Msg::PrintTimers() void Msg::ResetErrorCounter() { _warningCount = 0; _errorCount = 0; - _firstError.clear(); + _firstWarning.clear(); _firstError.clear(); #if defined(HAVE_FLTK) - if(FlGui::available()){ - FlGui::instance()->setLastStatus(); - } + if(FlGui::available()) FlGui::instance()->setLastStatus(); #endif } diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index b9fee7d6d89da09cbdcee4a26c3275fa33023e72..b21e37175ab2aa7dd0f456fc9d976d268289ebcc 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -36,7 +36,7 @@ class Msg { static std::map<std::string, double> _timers; // counters static int _warningCount, _errorCount; - static std::string _firstError; + static std::string _firstWarning, _firstError; // callback static GmshMessage *_callback; // command-line and startup time @@ -79,9 +79,11 @@ class Msg { static double &Timer(std::string str){ return _timers[str]; } static void PrintTimers(); static void ResetErrorCounter(); + static void PrintErrorCounter(const char *title); + static int GetWarningCount(){ return _warningCount; } static int GetErrorCount(){ return _errorCount; } + static std::string GetFirstWarning(){ return _firstWarning; } static std::string GetFirstError(){ return _firstError; } - static void PrintErrorCounter(const char *title); static double GetValue(const char *text, double defaultval); static std::string GetString(const char *text, std::string defaultval); static int GetAnswer(const char *question, int defaultval, const char *zero, diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 98ce08a6f3c2cb3f399cd4adc8ff03819eef47ba..87cd9ae3dde527979caf42824d7157b9b8af1b16 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -796,13 +796,15 @@ void FlGui::setStatus(const std::string &msg, bool opengl) _lastStatus = msg; static char buff[1024]; std::string tmp = std::string(" ") + msg; - if(Msg::GetErrorCount() && graph[0]->getMessageHeight() < FL_NORMAL_SIZE){ + int ne = Msg::GetErrorCount(), nw = Msg::GetWarningCount(); + if((ne || nw) && graph[0]->getMessageHeight() < FL_NORMAL_SIZE){ tmp += " - "; - char nerr[128]; sprintf(nerr, "%d", Msg::GetErrorCount()); - tmp += nerr; - tmp += (Msg::GetErrorCount() > 1) ? " Errors" : " Error"; - if(Msg::GetFirstError().size()) - tmp += " : Click to show messages [ ... " + Msg::GetFirstError() + " ... ]"; + char n[128]; sprintf(n, "%d", ne ? ne : nw); + tmp += n; + tmp += (ne > 1) ? " Errors" : ne ? " Error" : (nw > 1) ? " Warnings" : " Warning"; + tmp += " : Click to show messages [ ... "; + tmp += (ne ? Msg::GetFirstError() : Msg::GetFirstWarning()); + tmp += " ... ]"; } strncpy(buff, tmp.c_str(), sizeof(buff) - 1); buff[sizeof(buff) - 1] = '\0';