mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 14:54:14 +00:00
Avoid race condition when disposing of app
When disposing of the VirtViewerApp, we free the hash table containing the windows. This causes each window to be freed, which in turn causes the visibility callback to be invoked. This can then get NULL pointers from the self->priv->windows usage. Blank out priv->windows before unrefing the hashs and add a check to ensure priv->windows is non-NULL.
This commit is contained in:
parent
f34edd09cb
commit
d0de667ec2
@ -1254,9 +1254,13 @@ virt_viewer_app_dispose (GObject *object)
|
||||
VirtViewerAppPrivate *priv = self->priv;
|
||||
|
||||
if (priv->windows) {
|
||||
g_hash_table_unref(priv->windows);
|
||||
GHashTable *tmp = priv->windows;
|
||||
/* null-ify before unrefing, because we need
|
||||
* to prevent callbacks using priv->windows
|
||||
* while it is being disposed off. */
|
||||
priv->windows = NULL;
|
||||
priv->main_window = NULL;
|
||||
g_hash_table_unref(tmp);
|
||||
}
|
||||
|
||||
if (priv->container) {
|
||||
@ -1636,6 +1640,8 @@ window_update_menu_displays_cb(gpointer key G_GNUC_UNUSED,
|
||||
static void
|
||||
virt_viewer_app_update_menu_displays(VirtViewerApp *self)
|
||||
{
|
||||
if (!self->priv->windows)
|
||||
return;
|
||||
g_hash_table_foreach(self->priv->windows, window_update_menu_displays_cb, self);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user