shell-app: Stay consistent about application states

When the last interesting window of an app-backed window is removed,
we'll transition it back to STOPPED, but we transition the state and
send out the signal before we clear the running state.

This means that any listeners to the state-changed signal might
encounter a window-backed app that has a running state, but no
windows. If they call, e.g. shell_app_get_name, while in this state,
they'll encounter an assertion fail.
This commit is contained in:
Jasper St. Pierre 2015-07-16 15:56:00 -07:00
parent ff664fd1d8
commit 7424ee755a

View File

@ -1003,10 +1003,16 @@ _shell_app_remove_window (ShellApp *app,
if (!meta_window_is_skip_taskbar (window))
app->running_state->interesting_windows--;
shell_app_sync_running_state (app);
if (app->running_state && app->running_state->windows == NULL)
g_clear_pointer (&app->running_state, unref_running_state);
if (app->running_state->windows == NULL)
{
g_clear_pointer (&app->running_state, unref_running_state);
shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
}
else
{
shell_app_sync_running_state (app);
}
g_signal_emit (app, shell_app_signals[WINDOWS_CHANGED], 0);
}