Ensure windows are destroyed when display closes

When running virt-viewer with the --reconnect argument, when
the session closes, the VirtViewerWindow instances were being
freed, but not the GtkWindow itself. So the orphaned window
stayed around doing nothing. The GtkBuilder instance was also
leaked.

Fix these two leaks & also add some debugging to help future
troubleshooting
This commit is contained in:
Daniel P. Berrange 2012-05-04 16:37:36 +01:00
parent d0d226ca8f
commit f34edd09cb
4 changed files with 18 additions and 1 deletions

View File

@ -517,6 +517,7 @@ virt_viewer_app_remove_nth_window(VirtViewerApp *self, gint nth)
win = virt_viewer_app_get_nth_window(self, nth);
g_return_val_if_fail(win != NULL, FALSE);
DEBUG_LOG("Remove window %d %p", nth, win);
removed = g_hash_table_steal(self->priv->windows, &nth);
g_warn_if_fail(removed);
@ -536,6 +537,7 @@ virt_viewer_app_set_nth_window(VirtViewerApp *self, gint nth, VirtViewerWindow *
g_return_if_fail(virt_viewer_app_get_nth_window(self, nth) == NULL);
key = g_malloc(sizeof(gint));
*key = nth;
DEBUG_LOG("Insert window %d %p", nth, win);
g_hash_table_insert(self->priv->windows, key, win);
virt_viewer_app_set_window_subtitle(self, win, nth);

View File

@ -110,7 +110,7 @@ display_mark(SpiceChannel *channel G_GNUC_UNUSED,
gint mark,
VirtViewerDisplay *display)
{
DEBUG_LOG("display mark %d", mark);
DEBUG_LOG("Toggle monitor visibility %p %d", channel, mark);
virt_viewer_display_set_show_hint(display, mark);
}

View File

@ -427,6 +427,8 @@ virt_viewer_session_spice_channel_new(SpiceSession *s,
g_object_get(channel, "channel-id", &id, NULL);
DEBUG_LOG("New spice channel %p %s %d", channel, g_type_name(G_OBJECT_TYPE(channel)), id);
if (SPICE_IS_MAIN_CHANNEL(channel)) {
if (self->priv->main_channel != NULL)
g_signal_handlers_disconnect_by_func(self->priv->main_channel,
@ -522,6 +524,8 @@ virt_viewer_session_spice_channel_destroy(G_GNUC_UNUSED SpiceSession *s,
g_return_if_fail(self != NULL);
g_object_get(channel, "channel-id", &id, NULL);
DEBUG_LOG("Destroy SPICE channel %s %d", g_type_name(G_OBJECT_TYPE(channel)), id);
if (SPICE_IS_MAIN_CHANNEL(channel)) {
DEBUG_LOG("zap main channel");
if (channel == SPICE_CHANNEL(self->priv->main_channel))

View File

@ -179,6 +179,17 @@ virt_viewer_window_dispose (GObject *object)
priv->display = NULL;
}
DEBUG_LOG("Disposing window %p\n", object);
if (priv->window) {
gtk_widget_destroy(priv->window);
priv->window = NULL;
}
if (priv->builder) {
g_object_unref(priv->builder);
priv->builder = NULL;
}
g_free(priv->subtitle);
priv->subtitle = NULL;
}