From 18eaf729917f5ac3638d374d3cbc44e3fc2fa0c0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 1 Apr 2022 09:15:20 +0200 Subject: [PATCH] QSettings: fix a misleading comment Destructors in C++ are implicitly noexcept, so the try-catch around QSettingsPrivate::flush() is not to prevent throwing from a dtor (anymore), but to prevent a throw statement inside flush() from taking down the whole application. We don't need to care about abi::__forced_unwind here, since we couldn't re-throw it even if we wanted to (throw in noexcept function is direct std::terminate(); at least by not re-throwing, the user will get a nice complaint message from the runtime). Pick-to: 6.3 Change-Id: I3b24a4be9aeb74637a58725540990b535d005bdd Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 44faf0619c..026137a6d7 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2716,10 +2716,11 @@ QSettings::~QSettings() { Q_D(QSettings); if (d->pendingChanges) { + // Don't cause a failing flush() to std::terminate() the whole + // application - dtors are implicitly noexcept! QT_TRY { d->flush(); } QT_CATCH(...) { - ; // ok. then don't flush but at least don't throw in the destructor } } }