QException: honor the RO5
QException has an out-of-line destructor in order to pin its vtable. But like any std::exception subclass it's meant to be (and effectively is) copy-constructible and copy-assignable (cf. [exception]/2). Add the missing copy operations, and the default constructor. One may argue that this class should use some other approach since it also has a polymorphic clone() -- for instance disable assignments and make copy constructions protected -- but that ship has sailed. This prevents a Clang warning about the deprecated copies in the presence of a user-declared destructor. Change-Id: I4d8613ade265ea85a5a7e97255b75b7fcf3e5a27 Pick-to: 6.9 6.8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b42651c749
commit
793309693a
@ -82,10 +82,37 @@ QT_BEGIN_NAMESPACE
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
Destroys this QException object.
|
||||
*/
|
||||
QException::~QException() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QException::QException()
|
||||
|
||||
Constructs a QException object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QException::QException(const QException &other)
|
||||
|
||||
Creates a copy of \a other.
|
||||
|
||||
\note Be careful when using this function, as you risk slicing.
|
||||
|
||||
\sa clone()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QException &QException::operator=(const QException &other)
|
||||
|
||||
Copy-assigns \a other over this object.
|
||||
|
||||
\note Be careful when using this function, as you risk slicing.
|
||||
*/
|
||||
|
||||
void QException::raise() const
|
||||
{
|
||||
QException e = *this;
|
||||
|
@ -21,7 +21,10 @@ QT_BEGIN_NAMESPACE
|
||||
class Q_CORE_EXPORT QException : public std::exception
|
||||
{
|
||||
public:
|
||||
QException() = default;
|
||||
~QException() noexcept;
|
||||
QException(const QException &) = default;
|
||||
QException &operator=(const QException &) = default;
|
||||
virtual void raise() const;
|
||||
virtual QException *clone() const;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user