Skip to content

Commit 002387f

Browse files
committed
g-w-l/workspace-switcher: Fix random crash and errors when adding
and removing workspaces. gwl: Remove workspaces last-to-first when removing so the removal of lower-index workspaces won't affect the position of higher ones while they're being destroyed. workspace-switcher: Connect to 'workspaces-reordered', not 'workareas-changed', and perform a button refresh immediately when receiving these signals. The workareas-changed signal only fires from one place that the n_workspaces property notify is not, and it's also on an idle callback inside of muffin, so by the time workareas-changed got sent, the situation could have already changed, plus it would be the second signal received for the change (n_workspaces being updated immediately). The workspaces-reordered is called in that single instance that n_workspaces is not, so connect to that instead, since it's also immediate. ref: linuxmint/muffin@603dba89297695a53fe9 linuxmint/mint21-beta#89
1 parent e2bdd50 commit 002387f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,14 +922,16 @@ class GroupedWindowListApplet extends Applet.Applet {
922922
for (let i = 0; i < this.appLists.length; i++) {
923923
let workspaceIndex = this.appLists[i].metaWorkspace.index();
924924
if (workspaceIndex === -1) {
925-
this.appLists[i].destroy();
926-
this.appLists[i] = null;
925+
if (this.appLists[i] != null) {
926+
this.appLists[i].destroy();
927+
this.appLists[i] = null;
928+
}
927929
removedLists.push(i);
928930
} else {
929931
this.appLists[i].index = workspaceIndex;
930932
}
931933
}
932-
for (let i = 0; i < removedLists.length; i++) {
934+
for (let i = removedLists.length - 1; i >= 0; i--) {
933935
this.appLists.splice(removedLists[i], 1);
934936
}
935937
this.state.set({currentWs: global.screen.get_active_workspace_index()});

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ class CinnamonWorkspaceSwitcher extends Applet.Applet {
283283
this.actor.connect('scroll-event', this.hook.bind(this));
284284

285285
this.queueCreateButtons();
286-
global.screen.connect('notify::n-workspaces', Lang.bind(this, this.onNumberOfWorkspacesChanged));
287-
global.screen.connect('workareas-changed', Lang.bind(this, this.queueCreateButtons));
286+
global.workspace_manager.connect('notify::n-workspaces', () => { this.onWorkspacesUpdated() });
287+
global.workspace_manager.connect('workspaces-reordered', () => { this.onWorkspacesUpdated() });
288288
global.window_manager.connect('switch-workspace', this._onWorkspaceChanged.bind(this));
289289
global.settings.connect('changed::panel-edit-mode', Lang.bind(this, this.on_panel_edit_mode_changed));
290290

@@ -311,7 +311,7 @@ class CinnamonWorkspaceSwitcher extends Applet.Applet {
311311

312312
onNumberOfWorkspacesChanged() {
313313
this.removeWorkspaceMenuItem.setSensitive(global.screen.n_workspaces > 1);
314-
this.queueCreateButtons();
314+
this._createButtons();
315315
}
316316

317317
removeWorkspace (){

0 commit comments

Comments
 (0)