File indexing completed on 2025-01-18 10:07:23
0001
0002
0003
0004 #ifndef QTCORE_QEXCEPTION_H
0005 #define QTCORE_QEXCEPTION_H
0006
0007 #include <QtCore/qatomic.h>
0008 #include <QtCore/qshareddata.h>
0009
0010 #ifndef QT_NO_EXCEPTIONS
0011 # include <exception>
0012 #endif
0013
0014 QT_REQUIRE_CONFIG(future);
0015
0016 QT_BEGIN_NAMESPACE
0017
0018
0019 #if !defined(QT_NO_EXCEPTIONS) || defined(Q_QDOC)
0020
0021 class Q_CORE_EXPORT QException : public std::exception
0022 {
0023 public:
0024 ~QException() noexcept;
0025 virtual void raise() const;
0026 virtual QException *clone() const;
0027 };
0028
0029 class QUnhandledExceptionPrivate;
0030 class Q_CORE_EXPORT QUnhandledException final : public QException
0031 {
0032 public:
0033 QUnhandledException(std::exception_ptr exception = nullptr) noexcept;
0034 ~QUnhandledException() noexcept override;
0035
0036 QUnhandledException(QUnhandledException &&other) noexcept;
0037 QUnhandledException(const QUnhandledException &other) noexcept;
0038
0039 void swap(QUnhandledException &other) noexcept { d.swap(other.d); }
0040
0041 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUnhandledException)
0042 QUnhandledException &operator=(const QUnhandledException &other) noexcept;
0043
0044 void raise() const override;
0045 QUnhandledException *clone() const override;
0046
0047 std::exception_ptr exception() const;
0048
0049 private:
0050 QSharedDataPointer<QUnhandledExceptionPrivate> d;
0051 };
0052
0053 namespace QtPrivate {
0054
0055 class Q_CORE_EXPORT ExceptionStore
0056 {
0057 public:
0058 void setException(const QException &e);
0059 void setException(std::exception_ptr e);
0060 bool hasException() const;
0061 std::exception_ptr exception() const;
0062 void throwPossibleException();
0063 Q_NORETURN void rethrowException() const;
0064 std::exception_ptr exceptionHolder;
0065 };
0066
0067 }
0068
0069 #else
0070
0071 namespace QtPrivate {
0072
0073 class Q_CORE_EXPORT ExceptionStore
0074 {
0075 public:
0076 ExceptionStore() { }
0077 inline void throwPossibleException() {}
0078 inline void rethrowException() const { }
0079 };
0080
0081 }
0082
0083 #endif
0084
0085 QT_END_NAMESPACE
0086
0087 #endif