appDisplay: Don't leak duplicate items in AppView
If an icon already exists in an app view with the same id, the duplicate is not added on a call to addItem. Unfortunately, since it's not added, the icon actor gets orphaned and leaked. This commit address the problem by introducing a new hasItem method and disallowing callers to call addItem with a duplicate in the first place. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/628
This commit is contained in:
parent
32ddb6f739
commit
eaa32090b9
@ -128,10 +128,14 @@ class BaseAppView {
|
|||||||
return this._allItems;
|
return this._allItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasItem(id) {
|
||||||
|
return this._items[id] !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
addItem(icon) {
|
addItem(icon) {
|
||||||
let id = icon.id;
|
let id = icon.id;
|
||||||
if (this._items[id] !== undefined)
|
if (this.hasItem(id))
|
||||||
return;
|
throw new Error(`icon with id ${id} already added to view`)
|
||||||
|
|
||||||
this._allItems.push(icon);
|
this._allItems.push(icon);
|
||||||
this._items[id] = icon;
|
this._items[id] = icon;
|
||||||
@ -371,6 +375,8 @@ var AllView = class AllView extends BaseAppView {
|
|||||||
|
|
||||||
let folders = this._folderSettings.get_strv('folder-children');
|
let folders = this._folderSettings.get_strv('folder-children');
|
||||||
folders.forEach(id => {
|
folders.forEach(id => {
|
||||||
|
if (this.hasItem(id))
|
||||||
|
return;
|
||||||
let path = this._folderSettings.path + 'folders/' + id + '/';
|
let path = this._folderSettings.path + 'folders/' + id + '/';
|
||||||
let icon = new FolderIcon(id, path, this);
|
let icon = new FolderIcon(id, path, this);
|
||||||
icon.connect('name-changed', this._itemNameChanged.bind(this));
|
icon.connect('name-changed', this._itemNameChanged.bind(this));
|
||||||
@ -1151,6 +1157,9 @@ var FolderIcon = class FolderIcon {
|
|||||||
let excludedApps = this._folder.get_strv('excluded-apps');
|
let excludedApps = this._folder.get_strv('excluded-apps');
|
||||||
let appSys = Shell.AppSystem.get_default();
|
let appSys = Shell.AppSystem.get_default();
|
||||||
let addAppId = appId => {
|
let addAppId = appId => {
|
||||||
|
if (this.view.hasItem(appId))
|
||||||
|
return;
|
||||||
|
|
||||||
if (excludedApps.includes(appId))
|
if (excludedApps.includes(appId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user