Skip to content
Snippets Groups Projects
Commit 0216d7a3 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

[i674] New report mechanism for unhandled exceptions (#674 pt1) ()

Merging branch 'i674'  into 'r21'.

See merge request !1820
parents cb8a4464 f48dd2b5
No related branches found
No related tags found
2 merge requests!1844rebase on r21 of 4aug,!1820New report mechanism for unhandled exceptions (#674 pt1)
Pipeline #107603 passed
......@@ -27,51 +27,63 @@
#include <QMetaType>
#include <QtGlobal>
void custom_terminate_handler()
{
try {
std::rethrow_exception(std::current_exception());
} catch (const std::exception& ex) {
std::cerr << "terminate called after throwing an instance of 'std::runtime_error'\n"
<< "what():" << std::endl;
std::cerr << ex.what() << std::endl;
int argc;
char* argv[1];
QApplication app(argc, argv); // needed to run QMessageBox
QMessageBox msgbox(QMessageBox::Critical, "BornAgain: fatal bug",
QString("Sorry, you encountered a fatal bug.\n"
"The application will terminate.\n"
"Please note the following and inform the maintainers.\n\n")
+ ex.what() + "\n",
QMessageBox::Ok, nullptr);
msgbox.exec();
}
}
int main(int argc, char* argv[])
{
std::set_terminate(custom_terminate_handler);
ApplicationOptions options(argc, argv);
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
qRegisterMetaType<QVector<double>>("QVector<double>");
int ret = -1;
try {
QApplication app(argc, argv);
app.setApplicationName("BornAgain");
app.setApplicationVersion(GUI::Base::Path::getBornAgainVersionString());
app.setOrganizationName("BornAgain");
QApplication app(argc, argv);
app.setApplicationName("BornAgain");
app.setApplicationVersion(GUI::Base::Path::getBornAgainVersionString());
app.setOrganizationName("BornAgain");
#ifndef Q_OS_MAC
app.setWindowIcon(QIcon(":/images/BornAgain.ico"));
app.setWindowIcon(QIcon(":/images/BornAgain.ico"));
#endif
ApplicationSettings applicationSettings;
ApplicationSettings applicationSettings;
auto style = applicationSettings.styleToUse();
applicationSettings.loadStyle(style);
auto style = applicationSettings.styleToUse();
applicationSettings.loadStyle(style);
QString dir = GUI::Base::Path::appDataFolder();
if (!QDir().exists(dir))
QDir().mkpath(dir);
QString dir = GUI::Base::Path::appDataFolder();
if (!QDir().exists(dir))
QDir().mkpath(dir);
MainWindow win;
GUI::Global::mainWindow = &win;
if (options.find("geometry"))
win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
win.show();
MainWindow win;
GUI::Global::mainWindow = &win;
if (options.find("geometry"))
win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
win.show();
ret = app.exec();
} catch (const std::exception& ex) {
QApplication app(argc, argv);
QMessageBox msgbox(QMessageBox::Critical, "BornAgain: fatal bug",
QString("Sorry, you encountered a fatal bug.\n"
"The application will terminate.\n"
"Please note the following and inform the maintainers.\n\n")
+ ex.what() + "\n",
QMessageBox::Ok, nullptr);
msgbox.exec();
return 1;
}
ret = app.exec();
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment