Newer
Older
Gigg, Martyn Anthony
committed
//=============================
//MantidApplciation definitions
//==============================
#include "MantidApplication.h"
Steve Williams
committed
#include "MantidQtAPI/MantidDialog.h"
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
#include <QMessageBox>
#include <QPushButton>
#include <iostream>
namespace
{
/// static logger
Mantid::Kernel::Logger g_log("MantidApplication");
}
Gigg, Martyn Anthony
committed
/// Constructor
MantidApplication::MantidApplication(int &argc, char ** argv ) : QApplication(argc, argv)
{
}
bool MantidApplication::notify( QObject * receiver, QEvent * event )
{
bool res = false;
try
{
res = QApplication::notify(receiver,event);
}
Gigg, Martyn Anthony
committed
{
Roman Tolchenov
committed
if (MantidQt::API::MantidDialog::handle(receiver,e))
return true; // stops event propagation
// Restore possible override cursor
while(QApplication::overrideCursor())
{
QApplication::restoreOverrideCursor();
}
Roman Tolchenov
committed
g_log.fatal()<<"Unexpected exception: "<<e.what()<<"\n";
Gigg, Martyn Anthony
committed
QMessageBox ask;
QAbstractButton *terminateButton = ask.addButton(tr("Terminate"), QMessageBox::ActionRole);
ask.addButton(tr("Continue"), QMessageBox::ActionRole);
ask.setText("Sorry, MantidPlot has caught an unexpected exception:\n\n"+QString::fromStdString(e.what())+
"\n\nWould you like to terminate MantidPlot or try to continue working?\nIf you choose to continue it is advisable to save your data and restart the application.");
Gigg, Martyn Anthony
committed
ask.setIcon(QMessageBox::Critical);
ask.exec();
if (ask.clickedButton() == terminateButton)
{
g_log.fatal("Terminated by user.");
quit();
}else
g_log.fatal("Continue working.");
Gigg, Martyn Anthony
committed
}
{
g_log.fatal()<<"Unknown exception\n";
QMessageBox ask;
QAbstractButton *terminateButton = ask.addButton(tr("Terminate"), QMessageBox::ActionRole);
ask.addButton(tr("Continue"), QMessageBox::ActionRole);
ask.setText("Sorry, MantidPlot has caught an unexpected exception"\
"\n\nWould you like to terminate MantidPlot or try to continue working?\nIf you choose to continue it is advisable to save your data and restart the application.");
ask.setIcon(QMessageBox::Critical);
ask.exec();
if (ask.clickedButton() == terminateButton)
{
g_log.fatal("Terminated by user.");
quit();
}else
g_log.fatal("Continue working.");
}
Gigg, Martyn Anthony
committed
return res;
}
//=============================================================================