From b6a5aff9b7781fb98529e9a4beab0c2f43ac55fe Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Thu, 15 Nov 2018 23:29:32 +0100 Subject: [PATCH] Improve the exception safety code sample MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch improves the code by showing better handling of the exit code. Change-Id: I10f44a93fe342bfd998b717f71ad16216e921d7b Fixes: QTBUG-71587 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> --- doc/src/howtos/exceptionsafety.qdoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/howtos/exceptionsafety.qdoc b/doc/src/howtos/exceptionsafety.qdoc index 0eb674c2..461f275e 100644 --- a/doc/src/howtos/exceptionsafety.qdoc +++ b/doc/src/howtos/exceptionsafety.qdoc @@ -116,13 +116,15 @@ QApplication app(argc, argv); ... try { - app.exec(); + int ret = app.exec(); } catch (const std::bad_alloc &) { // clean up here, e.g. save the session // and close all config files. - return 0; // exit the application + return EXIT_FAILURE; // exit the application } + ... + return ret; \endcode After an exception is thrown, the connection to the windowing server -- GitLab