Skip to content

shell/app: Avoid adding windows with a startup workspace twice

Changing the workspace of a window causes the window tracker to remove and add it to the app again. If this happens from within _shell_app_add_window() before the window has been added to the windows list, this will cause the check that is supposed to prevent adding the same window multiple times to fail and the window to be added twice. The app will then be considered still running after the last window has been closed. Then when clicking on the corresponding app icon, the shell would attempt to switch to a NULL workspace for the closed window instead of starting a new instance, resulting in a crash.

Changing the workspace also needs to happen after increasing the interesting window count, because otherwise removal of the window by the window tracker would trigger a uint underflow leading the app to be considered running with UINT_MAX interesting windows, despite having no windows, leading to crashes right after launching the app.

Fixes #3833 (closed)

Merge request reports