From 65d27aaa438842bc9d730af1ec28b24345c60982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 4 Jul 2018 14:55:28 +0000 Subject: [PATCH] automountManager: remove allowAutorun expire timeout on volume removal If the volume is removed before AUTORUN_EXPIRE_TIMEOUT_SECS seconds, we can stop the timeout earlier as there's nothing to unset, while the volume instance won't be valid anymore. https://bugzilla.gnome.org/show_bug.cgi?id=791233 (cherry picked from commit 9c41736a813354fd9291177b12f6c4f85bd1c5f7) --- js/ui/components/automountManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/ui/components/automountManager.js b/js/ui/components/automountManager.js index 2d8f3f8fb..a6cd85792 100644 --- a/js/ui/components/automountManager.js +++ b/js/ui/components/automountManager.js @@ -210,6 +210,10 @@ var AutomountManager = new Lang.Class({ }, _onVolumeRemoved(monitor, volume) { + if (volume._allowAutorunExpireId && volume._allowAutorunExpireId > 0) { + Mainloop.source_remove(volume._allowAutorunExpireId); + delete volume._allowAutorunExpireId; + } this._volumeQueue = this._volumeQueue.filter(element => (element != volume)); }, @@ -234,8 +238,10 @@ var AutomountManager = new Lang.Class({ _allowAutorunExpire(volume) { let id = Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, () => { volume.allowAutorun = false; + delete volume._allowAutorunExpireId; return GLib.SOURCE_REMOVE; }); + volume._allowAutorunExpireId = id; GLib.Source.set_name_by_id(id, '[gnome-shell] volume.allowAutorun'); } });