wayland/outputs: Use g_hash_table_steal_extended in _update_outputs
g_hash_table_steal leaked the MetaMonitorSpec key in the old compositor->outputs hash table: ==1059254== 62 (32 direct, 30 indirect) bytes in 1 blocks are definitely lost in loss record 8,232 of 13,059 ==1059254== at 0x48489F3: calloc (vg_replace_malloc.c:1340) ==1059254== by 0x4C65C19: g_malloc0 (gmem.c:133) ==1059254== by 0x4956FE8: meta_monitor_spec_clone (meta-monitor.c:108) ==1059254== by 0x4A7B9E8: meta_wayland_compositor_update_outputs (meta-wayland-outputs.c:555) ==1059254== by 0x4A7C09E: meta_wayland_outputs_init (meta-wayland-outputs.c:796) ==1059254== by 0x4A63B60: meta_wayland_compositor_new (meta-wayland.c:874) ==1059254== by 0x49B58D0: meta_context_start (meta-context.c:523) ==1059254== by 0x10A8D7: main (mutter.c:148) ==1059254== ==1059254== 62 (32 direct, 30 indirect) bytes in 1 blocks are definitely lost in loss record 8,233 of 13,059 ==1059254== at 0x48489F3: calloc (vg_replace_malloc.c:1340) ==1059254== by 0x4C65C19: g_malloc0 (gmem.c:133) ==1059254== by 0x4956FE8: meta_monitor_spec_clone (meta-monitor.c:108) ==1059254== by 0x4A7B9E8: meta_wayland_compositor_update_outputs (meta-wayland-outputs.c:555) ==1059254== by 0x4A7BA8C: on_monitors_changed (meta-wayland-outputs.c:572) ==1059254== by 0x4F5E9BF: g_closure_invoke (gclosure.c:833) ==1059254== by 0x4F72D82: signal_emit_unlocked_R.isra.0 (gsignal.c:3887) ==1059254== by 0x4F747A8: signal_emit_valist_unlocked (gsignal.c:3519) ==1059254== by 0x4F7A665: g_signal_emit_valist (gsignal.c:3262) ==1059254== by 0x4F7A722: g_signal_emit (gsignal.c:3582) ==1059254== by 0x49691BD: meta_monitor_manager_notify_monitors_changed (meta-monitor-manager.c:1241) ==1059254== by 0x496EA8D: meta_monitor_manager_rebuild (meta-monitor-manager.c:3968) v2: * Use g_autoptr. (Sebastian Wick, Jonas Ådahl) Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4149>
This commit is contained in:
parent
1e5a79451c
commit
4284371a26
@ -354,3 +354,5 @@ void meta_monitor_set_for_lease (MetaMonitor *monitor,
|
||||
|
||||
META_EXPORT_TEST
|
||||
gboolean meta_monitor_is_for_lease (MetaMonitor *monitor);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaMonitorSpec, meta_monitor_spec_free)
|
||||
|
@ -536,24 +536,26 @@ meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
|
||||
for (l = monitors; l; l = l->next)
|
||||
{
|
||||
MetaMonitor *monitor = l->data;
|
||||
MetaMonitorSpec *monitor_spec = meta_monitor_get_spec (monitor);
|
||||
MetaWaylandOutput *wayland_output = NULL;
|
||||
MetaMonitorSpec *lookup_monitor_spec = meta_monitor_get_spec (monitor);
|
||||
g_autoptr (MetaMonitorSpec) monitor_spec = NULL;
|
||||
g_autoptr (MetaWaylandOutput) wayland_output = NULL;
|
||||
|
||||
if (!meta_monitor_is_active (monitor))
|
||||
continue;
|
||||
|
||||
if (compositor->outputs)
|
||||
wayland_output = g_hash_table_lookup (compositor->outputs, monitor_spec);
|
||||
|
||||
if (wayland_output)
|
||||
g_hash_table_steal (compositor->outputs, monitor_spec);
|
||||
else
|
||||
wayland_output = meta_wayland_output_new (compositor, monitor);
|
||||
if (!compositor->outputs ||
|
||||
!g_hash_table_steal_extended (compositor->outputs, lookup_monitor_spec,
|
||||
(gpointer *) &monitor_spec,
|
||||
(gpointer *) &wayland_output))
|
||||
{
|
||||
monitor_spec = meta_monitor_spec_clone (lookup_monitor_spec),
|
||||
wayland_output = meta_wayland_output_new (compositor, monitor);
|
||||
}
|
||||
|
||||
wayland_output_update_for_output (wayland_output, monitor);
|
||||
g_hash_table_insert (new_table,
|
||||
meta_monitor_spec_clone (monitor_spec),
|
||||
wayland_output);
|
||||
g_steal_pointer (&monitor_spec),
|
||||
g_steal_pointer (&wayland_output));
|
||||
}
|
||||
|
||||
if (compositor->outputs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user