Skip to content

Fix error messages when a monitor is removed

When a monitor is disconnected, there are several errors (about one per icon on the desktop) like this:

Object St.Widget (0x564392b4f840), has been already deallocated - impossible
to access to it. This might be caused by the fact that the object has been
destroyed from C code using something such as destroy(), dispose(), or
remove() vfuncs
== Stack trace for context 0x564390eb94d0 ==
JS ERROR: TypeError: bgManager.backgroundActor is null
DesktopGrid<@desktop-icons@csoriano/desktopGrid.js:100:9
_addDesktopIcons/<@desktop-icons@csoriano/desktopManager.js:85:27
forEachBackgroundManager@desktop-icons@csoriano/desktopManager.js:506:5
_addDesktopIcons@desktop-icons@csoriano/desktopManager.js:84:9
_recreateDesktopIcons@desktop-icons@csoriano/desktopManager.js:80:9
_addDesktopIcons/</<@desktop-icons@csoriano/desktopManager.js:93:17
_backgroundDestroyed@desktop-icons@csoriano/desktopGrid.js:164:13
DesktopGrid</this._bgDestroyedId<@desktop-icons@csoriano/desktopGrid.js:101:19
destroy@resource:///org/gnome/shell/ui/background.js:704:13
wrapper@resource:///org/gnome/gjs/modules/_legacy.js:82:22
_updateBackgrounds@resource:///org/gnome/shell/ui/layout.js:457:13
wrapper@resource:///org/gnome/gjs/modules/_legacy.js:82:22
_monitorsChanged@resource:///org/gnome/shell/ui/layout.js:525:9
wrapper@resource:///org/gnome/gjs/modules/_legacy.js:82:22

This error is because when an actor from a DesktopGrid is destroyed, the destructor callback set in the DesktopManager object does a call to _recreateDesktopIcons(). This call should not be done there, because the DesktopGrid is still half-destroyed. All what that destructor should do are only housekeeping tasks, like removing that DesktopGrid from the list of grids; but the task of recreating the icons must be delegated to the callback of the "monitors-changed" signal, which will arrive when the monitor structures have been safely modified and everything is ready to be reconstructed.

Edited by Rastersoft

Merge request reports