• Olivier Fourdan's avatar
    gtksettings: Remove display from cache on closing · b1d55f2c
    Olivier Fourdan authored
    GTK caches the settings per display in a static `GArray`, keeping a
    reference to the `GdkDisplay` as the key.
    
    However, when closing the display, the corresponding entry is not
    removed from the cache in `GtkSettings`.
    
    So when reopening again a `GdkDisplay`, if the new address matches one
    of the previously closed display, the cache will return the existing
    `GtkSettings` from the cache, which still holds a reference to the old
    `GdkScreen` which was freed along the `GdkDisplay`.
    
    To avoid the issue, make sure to remove the `GdkDisplay` and
    corresponding `GdkSettings` when closing the `GdkDisplay`.
    
    Also, care must be taken not to recreate the `GdkSettings` and re-add
    the `GdkDisplay` to the cache once the display is closed, and make sure
    callers of `gtk_settings_get_for_display()` can deal with a returned
    value being `NULL` if the display is closed.
    
    Fixes: commit 360a3c16 - "Use a cheaper way to store settings per
    display"
    b1d55f2c
gtkicontheme.c 169 KB