Safer setting of interval in QTimer
There are two methods which set the interval and do things afterwards. Setting the interval might trigger other code. This patch uses setValueBypassingBindings and marks the interval dirty later, just to be safe. Change-Id: I2cae3e4a9f040007dfd246c424250034e8df10a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
1a2dd92767
commit
a7ca8b1a28
@ -257,8 +257,9 @@ void QTimer::start()
|
||||
void QTimer::start(int msec)
|
||||
{
|
||||
Q_D(QTimer);
|
||||
d->inter = msec;
|
||||
d->inter.setValueBypassingBindings(msec);
|
||||
start();
|
||||
d->inter.markDirty();
|
||||
}
|
||||
|
||||
|
||||
@ -752,13 +753,14 @@ QBindable<bool> QTimer::bindableSingleShot()
|
||||
void QTimer::setInterval(int msec)
|
||||
{
|
||||
Q_D(QTimer);
|
||||
d->inter = msec;
|
||||
d->inter.setValueBypassingBindings(msec);
|
||||
if (d->id != INV_TIMER) { // create new timer
|
||||
QObject::killTimer(d->id); // restart timer
|
||||
d->id = QObject::startTimer(msec, d->type);
|
||||
// No need to call markDirty() for d->isActiveData here,
|
||||
// as timer state actually does not change
|
||||
}
|
||||
d->inter.markDirty();
|
||||
}
|
||||
|
||||
int QTimer::interval() const
|
||||
|
Loading…
Reference in New Issue
Block a user