BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MessageHandler.cpp File Reference

Description

Implements function MessageHandler.

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file MessageHandler.cpp.

Include dependency graph for MessageHandler.cpp:

Go to the source code of this file.

Functions

void MessageHandler (QtMsgType type, const QMessageLogContext &, const QString &msg)
 This is set by main to be the message handler of our GUI. More...
 

Function Documentation

◆ MessageHandler()

void MessageHandler ( QtMsgType  type,
const QMessageLogContext &  ,
const QString &  msg 
)

This is set by main to be the message handler of our GUI.

Definition at line 20 of file MessageHandler.cpp.

21 {
22  switch (type) {
23  case QtDebugMsg:
24  if (msg.size() == 0) // KDE will pass a zero-length msg qstring
25  break;
26  std::cerr << "DEBUG: " << msg.toStdString() << std::endl;
27  break;
28  case QtInfoMsg:
29  std::cerr << "INFO: " << msg.toStdString() << std::endl;
30  break;
31  case QtWarningMsg:
32  default:
33  if (msg.left(4) == "QXcb")
34  return;
35  std::cerr << "WARNING: " << msg.toStdString() << std::endl;
36  // QMessageBox::warning(QApplication::activeWindow(), qAppName(), msg);
37  break;
38  case QtFatalMsg:
39  std::cerr << "FATAL: " << msg.toStdString() << std::endl;
40  qApp->restoreOverrideCursor();
41  QMessageBox::critical(QApplication::activeWindow(), qAppName(),
42  "Sorry, you encountered a fatal bug.\n"
43  "The application will terminate.\n"
44  "Please note the following and inform the maintainers.\n\n"
45  + msg + "\n");
46  qApp->quit();
47  exit(1);
48  }
49 }

Referenced by main().