De-inline ctors/dtors in qabstractanimation_p.h

Also add explicit, where missing, and use NSDMI to simplify default
ctor implementations.

For the ctors, this is just about code hygiene. The classes are
exported, so de-inlining the ctors prevents them from being duplicated
in other libraries.

Ditto dtors, except in the case of dtors, being virtual functions, we
also avoid duplicating vtables, which has its own set of problems (see
bug-report).

Task-number: QTBUG-45582
Change-Id: I11536844b751f2e81269a5637153f84c8874ab10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2021-12-30 10:33:34 +01:00
parent 85c31d976f
commit bf81cd8d92
2 changed files with 39 additions and 7 deletions

View File

@ -227,6 +227,8 @@ QUnifiedTimer::QUnifiedTimer() :
driver = &defaultDriver;
}
QUnifiedTimer::~QUnifiedTimer()
= default;
QUnifiedTimer *QUnifiedTimer::instance(bool create)
{
@ -560,6 +562,9 @@ QAnimationTimer::QAnimationTimer() :
{
}
QAnimationTimer::~QAnimationTimer()
= default;
QAnimationTimer *QAnimationTimer::instance(bool create)
{
QAnimationTimer *inst;
@ -896,6 +901,9 @@ QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer)
connect(this, SIGNAL(stopped()), this, SLOT(stopTimer()));
}
QDefaultAnimationDriver::~QDefaultAnimationDriver()
= default;
void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
{
Q_ASSERT(e->timerId() == m_timer.timerId());
@ -914,6 +922,21 @@ void QDefaultAnimationDriver::stopTimer()
m_timer.stop();
}
QAnimationDriverPrivate::QAnimationDriverPrivate()
= default;
QAnimationDriverPrivate::~QAnimationDriverPrivate()
= default;
QAbstractAnimationTimer::QAbstractAnimationTimer()
= default;
QAbstractAnimationTimer::~QAbstractAnimationTimer()
= default;
QAbstractAnimationPrivate::QAbstractAnimationPrivate()
= default;
QAbstractAnimationPrivate::~QAbstractAnimationPrivate() { }
void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)

View File

@ -68,6 +68,7 @@ class QAbstractAnimation;
class QAbstractAnimationPrivate : public QObjectPrivate
{
public:
QAbstractAnimationPrivate();
virtual ~QAbstractAnimationPrivate();
static QAbstractAnimationPrivate *get(QAbstractAnimation *q)
@ -117,7 +118,8 @@ class QDefaultAnimationDriver : public QAnimationDriver
{
Q_OBJECT
public:
QDefaultAnimationDriver(QUnifiedTimer *timer);
explicit QDefaultAnimationDriver(QUnifiedTimer *timer);
~QDefaultAnimationDriver() override;
protected:
void timerEvent(QTimerEvent *e) override;
@ -134,24 +136,27 @@ private:
class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate
{
public:
QAnimationDriverPrivate() : running(false) {}
QAnimationDriverPrivate();
~QAnimationDriverPrivate() override;
QElapsedTimer timer;
bool running;
bool running = false;
};
class Q_CORE_EXPORT QAbstractAnimationTimer : public QObject
{
Q_OBJECT
public:
QAbstractAnimationTimer() : isRegistered(false), isPaused(false), pauseDuration(0) {}
QAbstractAnimationTimer();
~QAbstractAnimationTimer() override;
virtual void updateAnimationsTime(qint64 delta) = 0;
virtual void restartAnimationTimer() = 0;
virtual int runningAnimationCount() = 0;
bool isRegistered;
bool isPaused;
int pauseDuration;
bool isRegistered = false;
bool isPaused = false;
int pauseDuration = 0;
};
class Q_CORE_EXPORT QUnifiedTimer : public QObject
@ -161,6 +166,8 @@ private:
QUnifiedTimer();
public:
~QUnifiedTimer() override;
static QUnifiedTimer *instance();
static QUnifiedTimer *instance(bool create);
@ -252,6 +259,8 @@ private:
QAnimationTimer();
public:
~QAnimationTimer() override;
static QAnimationTimer *instance();
static QAnimationTimer *instance(bool create);