mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-11 17:29:46 +00:00
Queue only one update call in animations manager.
This commit is contained in:
parent
fe3181649b
commit
7808620764
@ -118,17 +118,25 @@ void Manager::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Manager::updateQueued() {
|
void Manager::updateQueued() {
|
||||||
InvokeQueued(this, [=] { update(); });
|
Expects(_timerId == 0);
|
||||||
|
|
||||||
|
_timerId = -1;
|
||||||
|
crl::on_main(delayedCallGuard(), [=] {
|
||||||
|
Expects(_timerId < 0);
|
||||||
|
|
||||||
|
_timerId = 0;
|
||||||
|
update();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::schedule() {
|
void Manager::schedule() {
|
||||||
if (_scheduled) {
|
if (_scheduled || _timerId < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stopTimer();
|
stopTimer();
|
||||||
|
|
||||||
_scheduled = true;
|
_scheduled = true;
|
||||||
Ui::PostponeCall(static_cast<QObject*>(this), [=] {
|
Ui::PostponeCall(delayedCallGuard(), [=] {
|
||||||
_scheduled = false;
|
_scheduled = false;
|
||||||
if (_forceImmediateUpdate) {
|
if (_forceImmediateUpdate) {
|
||||||
_forceImmediateUpdate = false;
|
_forceImmediateUpdate = false;
|
||||||
@ -145,8 +153,12 @@ void Manager::schedule() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<const QObject*> Manager::delayedCallGuard() const {
|
||||||
|
return static_cast<const QObject*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
void Manager::stopTimer() {
|
void Manager::stopTimer() {
|
||||||
if (_timerId) {
|
if (_timerId > 0) {
|
||||||
killTimer(base::take(_timerId));
|
killTimer(base::take(_timerId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ private:
|
|||||||
void schedule();
|
void schedule();
|
||||||
void updateQueued();
|
void updateQueued();
|
||||||
void stopTimer();
|
void stopTimer();
|
||||||
|
not_null<const QObject*> delayedCallGuard() const;
|
||||||
|
|
||||||
crl::time _lastUpdateTime = 0;
|
crl::time _lastUpdateTime = 0;
|
||||||
int _timerId = 0;
|
int _timerId = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user