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 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 793309693aac24e7f88fc225408d92def638996e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 37a553a3a51cfe58b73083432634ba4235401b10)
This commit is contained in:
parent
4b763eab23
commit
5e75ef6d8b
@ -82,10 +82,37 @@ QT_BEGIN_NAMESPACE
|
|||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destroys this QException object.
|
||||||
|
*/
|
||||||
QException::~QException() noexcept
|
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
|
void QException::raise() const
|
||||||
{
|
{
|
||||||
QException e = *this;
|
QException e = *this;
|
||||||
|
@ -21,7 +21,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
class Q_CORE_EXPORT QException : public std::exception
|
class Q_CORE_EXPORT QException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QException() = default;
|
||||||
~QException() noexcept;
|
~QException() noexcept;
|
||||||
|
QException(const QException &) = default;
|
||||||
|
QException &operator=(const QException &) = default;
|
||||||
virtual void raise() const;
|
virtual void raise() const;
|
||||||
virtual QException *clone() const;
|
virtual QException *clone() const;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user