Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
0216d7a3
Commit
0216d7a3
authored
1 year ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Plain Diff
[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
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1844
rebase on r21 of 4aug
,
!1820
New report mechanism for unhandled exceptions (#674 pt1)
Pipeline
#107603
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
App/main.cpp
+43
-31
43 additions, 31 deletions
App/main.cpp
with
43 additions
and
31 deletions
App/main.cpp
+
43
−
31
View file @
0216d7a3
...
...
@@ -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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment