Skip to content

Commit

Permalink
Replace qTerminate() with std::terminate() and mark it for removal
Browse files Browse the repository at this point in the history
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 9b2ae56. 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>
  • Loading branch information
thiagomacieira committed Dec 26, 2024
1 parent d9264ee commit b8f84fd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/corelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/corelib/compat/removed_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 0 additions & 20 deletions src/corelib/global/qexceptionhandling.cpp

This file was deleted.

5 changes: 4 additions & 1 deletion src/corelib/global/qexceptionhandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/corelib/thread/qthread_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void terminate_on_exception(T &&t)
throw;
#endif // __GLIBCXX__
} catch (...) {
qTerminate();
std::terminate();
}
#endif // QT_NO_EXCEPTIONS
}
Expand Down
2 changes: 1 addition & 1 deletion src/testlib/qtestresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace QTest
}();

if (failed && fatalFailure)
qTerminate();
std::terminate();
Internal::failed = failed;
}

Expand Down

0 comments on commit b8f84fd

Please sign in to comment.