mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-23 23:14:41 +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() {
|
||||
InvokeQueued(this, [=] { update(); });
|
||||
Expects(_timerId == 0);
|
||||
|
||||
_timerId = -1;
|
||||
crl::on_main(delayedCallGuard(), [=] {
|
||||
Expects(_timerId < 0);
|
||||
|
||||
_timerId = 0;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void Manager::schedule() {
|
||||
if (_scheduled) {
|
||||
if (_scheduled || _timerId < 0) {
|
||||
return;
|
||||
}
|
||||
stopTimer();
|
||||
|
||||
_scheduled = true;
|
||||
Ui::PostponeCall(static_cast<QObject*>(this), [=] {
|
||||
Ui::PostponeCall(delayedCallGuard(), [=] {
|
||||
_scheduled = false;
|
||||
if (_forceImmediateUpdate) {
|
||||
_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() {
|
||||
if (_timerId) {
|
||||
if (_timerId > 0) {
|
||||
killTimer(base::take(_timerId));
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,7 @@ private:
|
||||
void schedule();
|
||||
void updateQueued();
|
||||
void stopTimer();
|
||||
not_null<const QObject*> delayedCallGuard() const;
|
||||
|
||||
crl::time _lastUpdateTime = 0;
|
||||
int _timerId = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user