Replace qTerminate() with std::terminate() and mark it for removal

It was used by the QT_TERMINATE_ON_EXCEPTION macro, introduced in 2012,
to support pre-C++11 noexcept semantics. That macro was removed for Qt
6.8 in commit 9b2ae564a59656d9cf49b141e70f5958b4fb79a4. This commit
amends that removing the definition of qTerminate() immediately in Qt
6.9 (it was an \internal function).

Pick-to: 6.9
Change-Id: I9682121c04fafb3676b0fffd9f5ac999e7603c84
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2024-12-21 12:08:32 -03:00
parent d9264ee65d
commit b8f84fd1e2
7 changed files with 16 additions and 28 deletions

View File

@ -49,7 +49,7 @@ qt_internal_add_module(Core
global/qcontainerinfo.h
global/qdarwinhelpers.h
global/qendian.cpp global/qendian.h global/qendian_p.h
global/qexceptionhandling.cpp global/qexceptionhandling.h
global/qexceptionhandling.h
global/qflags.h
global/qfloat16.cpp global/qfloat16.h
global/qforeach.h

View File

@ -1248,6 +1248,15 @@ QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData) noexcept
#include "qchar.h" // inlined API
#include "qexceptionhandling.h"
Q_NORETURN void qTerminate() noexcept
{
std::terminate();
}
#include "qmetatype.h"
bool QMetaType::isRegistered() const

View File

@ -686,10 +686,6 @@ bool readConfiguration(const QFile &file)
process(ch); // ERROR: ch is copied from deleted memory
//! [as-const-4]
//! [qterminate]
try { expr; } catch(...) { qTerminate(); }
//! [qterminate]
//! [qdecloverride]
// generate error if this doesn't actually override anything:
virtual void MyWidget::paintEvent(QPaintEvent*) override;

View File

@ -1,20 +0,0 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qexceptionhandling.h"
#include <exception>
QT_BEGIN_NAMESPACE
/*
\internal
Allows you to call std::terminate() without including <exception>.
Called internally from QT_TERMINATE_ON_EXCEPTION
*/
Q_NORETURN void qTerminate() noexcept
{
std::terminate();
}
QT_END_NAMESPACE

View File

@ -22,7 +22,6 @@ QT_BEGIN_NAMESPACE
If you can't live with those constraints, don't use these macros.
Use the QT_NO_EXCEPTIONS macro to protect your code instead.
*/
Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept;
#ifdef QT_NO_EXCEPTIONS
# define QT_TRY if (true)
# define QT_CATCH(A) else
@ -35,6 +34,10 @@ Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept;
# define QT_RETHROW throw
#endif
#if QT_CORE_REMOVED_SINCE(6, 9)
Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept;
#endif
QT_END_NAMESPACE
#endif // QEXCEPTIONHANDLING_H

View File

@ -319,7 +319,7 @@ void terminate_on_exception(T &&t)
throw;
#endif // __GLIBCXX__
} catch (...) {
qTerminate();
std::terminate();
}
#endif // QT_NO_EXCEPTIONS
}

View File

@ -43,7 +43,7 @@ namespace QTest
}();
if (failed && fatalFailure)
qTerminate();
std::terminate();
Internal::failed = failed;
}