Newer
Older
// ************************************************************************************************
// BornAgain: simulate and fit reflection and scattering
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
// ************************************************************************************************

Wuttke, Joachim
committed
#include "Base/Util/Assert.h"
#include "GUI/Model/Util/Path.h"
#include "GUI/View/Base/Stylesheet.h"
#include "GUI/View/Widget/AppConfig.h"
#include "PyCore/Embed/PyInterpreter.h" // PyInterpreter::finalize
#include "config_build.h"

Wuttke, Joachim
committed
#include <QApplication>
#include <QMessageBox>

Wuttke, Joachim
committed
#include <QtGlobal>
void custom_terminate_handler()
{
try {
std::rethrow_exception(std::current_exception());
} catch (const std::exception& ex) {
std::cerr << "terminate called after throwing a std exception'\n"
<< "what():" << std::endl;
std::cerr << ex.what() << std::endl;
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>");

Wuttke, Joachim
committed
int ret = -1;
QApplication app(argc, argv);
app.setApplicationName("BornAgain");
app.setApplicationVersion(GUI::Path::getBornAgainVersionString());
app.setWindowIcon(QIcon(":/images/BornAgain.ico"));
GUI::Style::setInitialStyle();

Wuttke, Joachim
committed
gApp = std::make_unique<AppConfig>();

Wuttke, Joachim
committed
if (options.find("geometry"))
win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
win.show();
#ifdef BORNAGAIN_PYTHON
std::cout << "BornAgain: finalize Python interpreter..." << std::endl;
PyInterpreter::finalize();
#endif // BORNAGAIN_PYTHON