Fix QTimer::setInterval to remove existing bindings
A recent change ( a7ca8b1a2864e47cacd530f6b10d2b415c5193f7 ) led to failure of binding removal in setInterval(). This was fixed by introducing setterScope. This patch add unit tests for this regression. Change-Id: Ic8da1f2d82ad6c8ccd81c9b1eff72d42cf75f28a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
2fe6f551d9
commit
6bdffefaa8
@ -257,6 +257,7 @@ void QTimer::start()
|
|||||||
void QTimer::start(int msec)
|
void QTimer::start(int msec)
|
||||||
{
|
{
|
||||||
Q_D(QTimer);
|
Q_D(QTimer);
|
||||||
|
d->inter.removeBindingUnlessInWrapper();
|
||||||
d->inter.setValueBypassingBindings(msec);
|
d->inter.setValueBypassingBindings(msec);
|
||||||
start();
|
start();
|
||||||
d->inter.markDirty();
|
d->inter.markDirty();
|
||||||
@ -753,6 +754,8 @@ QBindable<bool> QTimer::bindableSingleShot()
|
|||||||
void QTimer::setInterval(int msec)
|
void QTimer::setInterval(int msec)
|
||||||
{
|
{
|
||||||
Q_D(QTimer);
|
Q_D(QTimer);
|
||||||
|
d->inter.removeBindingUnlessInWrapper();
|
||||||
|
|
||||||
d->inter.setValueBypassingBindings(msec);
|
d->inter.setValueBypassingBindings(msec);
|
||||||
if (d->id != INV_TIMER) { // create new timer
|
if (d->id != INV_TIMER) { // create new timer
|
||||||
QObject::killTimer(d->id); // restart timer
|
QObject::killTimer(d->id); // restart timer
|
||||||
@ -760,6 +763,7 @@ void QTimer::setInterval(int msec)
|
|||||||
// No need to call markDirty() for d->isActiveData here,
|
// No need to call markDirty() for d->isActiveData here,
|
||||||
// as timer state actually does not change
|
// as timer state actually does not change
|
||||||
}
|
}
|
||||||
|
|
||||||
d->inter.markDirty();
|
d->inter.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,6 +1158,10 @@ void tst_QTimer::bindTimer()
|
|||||||
QCOMPARE(timer.interval(), 10);
|
QCOMPARE(timer.interval(), 10);
|
||||||
interval = 100;
|
interval = 100;
|
||||||
QCOMPARE(timer.interval(), 100);
|
QCOMPARE(timer.interval(), 100);
|
||||||
|
timer.setInterval(50);
|
||||||
|
QCOMPARE(timer.interval(), 50);
|
||||||
|
interval = 30;
|
||||||
|
QCOMPARE(timer.interval(), 50);
|
||||||
|
|
||||||
// timerType property
|
// timerType property
|
||||||
QCOMPARE(timer.timerType(), Qt::CoarseTimer);
|
QCOMPARE(timer.timerType(), Qt::CoarseTimer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user