Commit b6a5aff9 authored by Samuel Gaist's avatar Samuel Gaist
Browse files

Improve the exception safety code sample


This patch improves the code by showing better handling of the exit
code.

Change-Id: I10f44a93fe342bfd998b717f71ad16216e921d7b
Fixes: QTBUG-71587
Reviewed-by: default avatarTopi Reiniö <topi.reinio@qt.io>
Showing with 4 additions and 2 deletions
...@@ -116,13 +116,15 @@ ...@@ -116,13 +116,15 @@
QApplication app(argc, argv); QApplication app(argc, argv);
... ...
try { try {
app.exec(); int ret = app.exec();
} catch (const std::bad_alloc &) { } catch (const std::bad_alloc &) {
// clean up here, e.g. save the session // clean up here, e.g. save the session
// and close all config files. // and close all config files.
return 0; // exit the application return EXIT_FAILURE; // exit the application
} }
...
return ret;
\endcode \endcode
After an exception is thrown, the connection to the windowing server After an exception is thrown, the connection to the windowing server
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment