diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 6b6836df811..df7aa0eed2b 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -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 diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index bdb811a1d0d..751c1995eda 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -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 diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index 25d3abf67ea..393bd5778f1 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -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; diff --git a/src/corelib/global/qexceptionhandling.cpp b/src/corelib/global/qexceptionhandling.cpp deleted file mode 100644 index f74eb495464..00000000000 --- a/src/corelib/global/qexceptionhandling.cpp +++ /dev/null @@ -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 - -QT_BEGIN_NAMESPACE - -/* - \internal - Allows you to call std::terminate() without including . - Called internally from QT_TERMINATE_ON_EXCEPTION -*/ -Q_NORETURN void qTerminate() noexcept -{ - std::terminate(); -} - -QT_END_NAMESPACE diff --git a/src/corelib/global/qexceptionhandling.h b/src/corelib/global/qexceptionhandling.h index 7ffd0798f6f..6c547a90630 100644 --- a/src/corelib/global/qexceptionhandling.h +++ b/src/corelib/global/qexceptionhandling.h @@ -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 diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 926b7aea400..fc9ab3aa1a6 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -319,7 +319,7 @@ void terminate_on_exception(T &&t) throw; #endif // __GLIBCXX__ } catch (...) { - qTerminate(); + std::terminate(); } #endif // QT_NO_EXCEPTIONS } diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 4a6fb5918d7..39b4c0559d9 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -43,7 +43,7 @@ namespace QTest }(); if (failed && fatalFailure) - qTerminate(); + std::terminate(); Internal::failed = failed; }