AutorunManager: fix regression from the components rewrite

Message tray sources cannot be reused after destruction, so connect
to 'destroy' signal and clear out the previous one.
Also, fix some code paths that used the autorun manager incorrectly.

https://bugzilla.gnome.org/show_bug.cgi?id=683377
This commit is contained in:
Giovanni Campagna 2012-09-05 02:24:56 +02:00
parent 0725a7d836
commit 09c81f79f6

View File

@ -150,8 +150,18 @@ const AutorunManager = new Lang.Class({
this._transDispatcher = new AutorunTransientDispatcher(this); this._transDispatcher = new AutorunTransientDispatcher(this);
}, },
enable: function() { _ensureResidentSource: function() {
if (this._residentSource)
return;
this._residentSource = new AutorunResidentSource(this); this._residentSource = new AutorunResidentSource(this);
let destroyId = this._residentSource.connect('destroy', Lang.bind(this, function() {
this._residentSource.disconnect(destroyId);
this._residentSource = null;
}));
},
enable: function() {
this._scanMounts(); this._scanMounts();
this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded)); this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded));
@ -169,6 +179,7 @@ const AutorunManager = new Lang.Class({
mounts.forEach(Lang.bind(this, function (mount) { mounts.forEach(Lang.bind(this, function (mount) {
let discoverer = new ContentTypeDiscoverer(Lang.bind (this, let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps) { function (mount, apps) {
this._ensureResidentSource();
this._residentSource.addMount(mount, apps); this._residentSource.addMount(mount, apps);
})); }));
@ -185,6 +196,7 @@ const AutorunManager = new Lang.Class({
let discoverer = new ContentTypeDiscoverer(Lang.bind (this, let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps, contentTypes) { function (mount, apps, contentTypes) {
this._transDispatcher.addMount(mount, apps, contentTypes); this._transDispatcher.addMount(mount, apps, contentTypes);
this._ensureResidentSource();
this._residentSource.addMount(mount, apps); this._residentSource.addMount(mount, apps);
})); }));
@ -193,6 +205,7 @@ const AutorunManager = new Lang.Class({
_onMountRemoved: function(monitor, mount) { _onMountRemoved: function(monitor, mount) {
this._transDispatcher.removeMount(mount); this._transDispatcher.removeMount(mount);
if (this._residentSource)
this._residentSource.removeMount(mount); this._residentSource.removeMount(mount);
}, },
@ -266,8 +279,8 @@ const AutorunResidentSource = new Lang.Class({
this._mounts = []; this._mounts = [];
this._notification = new AutorunResidentNotification(this._manager, this);
this._manager = manager; this._manager = manager;
this._notification = new AutorunResidentNotification(this._manager, this);
}, },
addMount: function(mount, apps) { addMount: function(mount, apps) {
@ -384,7 +397,7 @@ const AutorunResidentNotification = new Lang.Class({
// now connect signals // now connect signals
mountButton.connect('clicked', Lang.bind(this, function(actor, event) { mountButton.connect('clicked', Lang.bind(this, function(actor, event) {
this._manager.startAppForMount(apps[0], mount); startAppForMount(apps[0], mount);
})); }));
ejectButton.connect('clicked', Lang.bind(this, function() { ejectButton.connect('clicked', Lang.bind(this, function() {