Skip to content

Commit

Permalink
BackgroundSource: Keep a reference to the monitor manager
Browse files Browse the repository at this point in the history
Make sure that we will have the same object on destroy.
  • Loading branch information
tintou committed Sep 29, 2023
1 parent 86ae6b6 commit 2c8f786
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Background/BackgroundSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Gala {

private GLib.HashTable<int, Background> backgrounds;
private uint[] hash_cache;
private Meta.MonitorManager? monitor_manager;

public BackgroundSource (Meta.Display display, string settings_schema) {
Object (display: display, settings: new Settings (settings_schema));
Expand All @@ -46,7 +47,7 @@ namespace Gala {
backgrounds = new GLib.HashTable<int, Background> (GLib.direct_hash, GLib.direct_equal);
hash_cache = new uint[OPTIONS.length];

unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.connect (monitors_changed);

// unfortunately the settings sometimes tend to fire random changes even though
Expand Down Expand Up @@ -139,8 +140,8 @@ namespace Gala {
}

public void destroy () {
unowned var monitor_manager = display.get_context ().get_backend ().get_monitor_manager ();
monitor_manager.monitors_changed.disconnect (monitors_changed);
monitor_manager = null;

backgrounds.foreach_remove ((hash, background) => {
background.changed.disconnect (background_changed);
Expand All @@ -150,3 +151,4 @@ namespace Gala {
}
}
}

0 comments on commit 2c8f786

Please sign in to comment.