Skip to content
Snippets Groups Projects
Commit b914187c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

extend notifications to warnings

parent 17c6f8ef
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
......@@ -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,
......
......@@ -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';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment