loginDialog: Ensure old timed login timeout is removed before starting a new one

Normally, we give the user a 5 second grace period of inactivity before
starting a timed login operation. Unfortunately, that grace period
timeout isn't properly removed if the timed login operation is restarted
during the grace period. That means the timeout handler can
inadvertently get called multiple times leading to the grace period
duration getting subtracted from the total animation time more than
once.

This commit ensures we only ever have one grace period timeout scheduled
at a time.
This commit is contained in:
verdre 2018-04-17 14:51:20 +02:00
parent b1239b1257
commit 522a5fe480

View File

@ -1010,6 +1010,7 @@ var LoginDialog = new Lang.Class({
this._timedLoginIdleTimeOutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, _TIMED_LOGIN_IDLE_THRESHOLD,
() => {
this._timedLoginAnimationTime -= _TIMED_LOGIN_IDLE_THRESHOLD;
this._timedLoginIdleTimeOutId = 0;
hold.release();
return GLib.SOURCE_REMOVE;
});
@ -1024,6 +1025,12 @@ var LoginDialog = new Lang.Class({
this._timedLoginBatch = null;
}
// Reset previous idle-timeout
if (this._timedLoginIdleTimeOutId) {
GLib.source_remove(this._timedLoginIdleTimeOutId);
this._timedLoginIdleTimeOutId = 0;
}
this._timedLoginItem = null;
this._timedLoginDelay = delay;
this._timedLoginAnimationTime = delay;