mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 14:54:14 +00:00
VirtViewerApp: Never remove main window
It's currently possible to destroy any virt-viewer window, including the main window. However, some part of the code expects that the main window is always present, for example to present status messages. In particular, stopping the guest (or running virsh destroy) will close all windows: virt_viewer_session_clear_displays will get called, which will call into virt_viewer_app_remove_display_removed, and finally into virt_viewer_app_remove_nth_window, which will destroy the window being removed if it holds the last reference to it. So going through virt_viewer_session_clear_displays, all VirtViewerWindow instances and their corresponding GtkWindow have been destroyed. This is already an issue as VirtViewerApp::main_window will be pointing to freed memory. When using virt-viewer --reconnect, this will cause a crash when restarting the guest in virt_viewer_app_create_session as it tries to get a valid GtkWindow through: GtkWindow *window = virt_viewer_window_get_window(priv->main_window); This commit avoids this issue by special casing the main window in virt_viewer_app_remove_nth_window to ensure it never gets removed. This is similar to what is done in virt_viewer_app_hide_all_windows.
This commit is contained in:
parent
1c341e8cb3
commit
1c69f3cf40
@ -977,8 +977,11 @@ static void virt_viewer_app_remove_nth_window(VirtViewerApp *self,
|
||||
VirtViewerWindow *win = virt_viewer_app_get_nth_window(self, nth);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
virt_viewer_window_set_display(win, NULL);
|
||||
if (win == self->priv->main_window) {
|
||||
g_debug("Not removing main window %d %p", nth, win);
|
||||
return;
|
||||
}
|
||||
virt_viewer_window_hide(win);
|
||||
|
||||
g_debug("Remove window %d %p", nth, win);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user