Skip to content

Commit fdfd909

Browse files
committed
added messagebox when restoring last session crashes
1 parent 98207d7 commit fdfd909

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

source/annotator/source/main/main.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include "mainwindow.h"
21
#include <Poco/Exception.h>
2+
#include <sys/stat.h>
33
#include <QApplication>
4+
#include <QMessageBox>
45
#include <QSettings>
5-
#include <sys/stat.h>
6+
#include "mainwindow.h"
67

78
#ifdef OPTION_INCLUDE_CRASHCPP
89
#include <crashcpp/crashcpp.h>
@@ -43,15 +44,28 @@ int main(int argc, char *argv[]) {
4344
QString lastProjPath = settings.value("LastProjectPath", "").toString();
4445

4546
// check if path was stored previously
46-
if (!lastProjPath.isEmpty()) {
47-
// check if file exists on fs
48-
struct stat buffer;
49-
if (stat(lastProjPath.toStdString().c_str(), &buffer) == 0)
50-
w.openProject(AnnotatorLib::Project::load(lastProjPath.toStdString()));
47+
try {
48+
if (!lastProjPath.isEmpty()) {
49+
// check if file exists on fs
50+
struct stat buffer;
51+
if (stat(lastProjPath.toStdString().c_str(), &buffer) == 0)
52+
w.openProject(AnnotatorLib::Project::load(lastProjPath.toStdString()));
53+
}
54+
} catch (Poco::Exception &e) {
55+
QMessageBox::critical(
56+
nullptr, "Critical error while loading last session.",
57+
"Last session coult not been loaded causing following error: " +
58+
QString::fromStdString(e.message()));
59+
} catch (std::exception &e) {
60+
QMessageBox::critical(
61+
nullptr, "Critical error while loading last session.",
62+
"Last session coult not been loaded causing following error: " +
63+
QString::fromStdString(e.what()));
5164
}
5265

5366
/*
54-
* If an unhandled exception occurs, the exception will be sent to crashcpp.chriamue.de
67+
* If an unhandled exception occurs, the exception will be sent to
68+
* crashcpp.chriamue.de
5569
*/
5670
try {
5771
return a.exec();

0 commit comments

Comments
 (0)