summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <[email protected]>2024-12-21 12:08:32 -0300
committerThiago Macieira <[email protected]>2024-12-26 08:34:38 -0300
commitb8f84fd1e2af38ece89d60619bf93e7af34433ab (patch)
tree86258cbb7e6570d178d6965ae033e008a9ca3596
parentd9264ee65d6f24e1008b08494b1472a54ac01940 (diff)
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 <[email protected]>
-rw-r--r--src/corelib/CMakeLists.txt2
-rw-r--r--src/corelib/compat/removed_api.cpp9
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp4
-rw-r--r--src/corelib/global/qexceptionhandling.cpp20
-rw-r--r--src/corelib/global/qexceptionhandling.h5
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/testlib/qtestresult.cpp2
7 files changed, 16 insertions, 28 deletions
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 <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
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;
}