|
|
79df40 |
From d585e6d6f15122ca58995603cfc67bfeb111b0d8 Mon Sep 17 00:00:00 2001
|
|
|
79df40 |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
79df40 |
Date: Thu, 25 Jul 2019 01:24:01 +0200
|
|
|
79df40 |
Subject: [PATCH 23/28] monitor-config-migration: Unref the new config once
|
|
|
79df40 |
added to the store
|
|
|
79df40 |
|
|
|
79df40 |
When migrating the configurations we've a leak because the config is passed to
|
|
|
79df40 |
the store that takes its ownership via meta_monitor_config_store_add(), but we
|
|
|
79df40 |
never relase the reference of the newly created object.
|
|
|
79df40 |
|
|
|
79df40 |
So use an auto-pointer to manage the object lifetime when returning.
|
|
|
79df40 |
|
|
|
79df40 |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
|
|
|
79df40 |
---
|
|
|
79df40 |
src/backends/meta-monitor-config-migration.c | 3 +--
|
|
|
79df40 |
1 file changed, 1 insertion(+), 2 deletions(-)
|
|
|
79df40 |
|
|
|
79df40 |
diff --git a/src/backends/meta-monitor-config-migration.c b/src/backends/meta-monitor-config-migration.c
|
|
|
79df40 |
index d619dc433..ed6c80184 100644
|
|
|
79df40 |
--- a/src/backends/meta-monitor-config-migration.c
|
|
|
79df40 |
+++ b/src/backends/meta-monitor-config-migration.c
|
|
|
79df40 |
@@ -1067,94 +1067,93 @@ find_disabled_monitor_specs (MetaLegacyMonitorsConfig *legacy_config)
|
|
|
79df40 |
MetaOutputKey *output_key = &legacy_config->keys[i];
|
|
|
79df40 |
MetaOutputConfig *output_config = &legacy_config->outputs[i];
|
|
|
79df40 |
MetaMonitorSpec *monitor_spec;
|
|
|
79df40 |
|
|
|
79df40 |
if (output_config->enabled)
|
|
|
79df40 |
continue;
|
|
|
79df40 |
|
|
|
79df40 |
monitor_spec = g_new0 (MetaMonitorSpec, 1);
|
|
|
79df40 |
*monitor_spec = (MetaMonitorSpec) {
|
|
|
79df40 |
.connector = output_key->connector,
|
|
|
79df40 |
.vendor = output_key->vendor,
|
|
|
79df40 |
.product = output_key->product,
|
|
|
79df40 |
.serial = output_key->serial
|
|
|
79df40 |
};
|
|
|
79df40 |
|
|
|
79df40 |
disabled_monitors = g_list_prepend (disabled_monitors, monitor_spec);
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
return disabled_monitors;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
static void
|
|
|
79df40 |
migrate_config (gpointer key,
|
|
|
79df40 |
gpointer value,
|
|
|
79df40 |
gpointer user_data)
|
|
|
79df40 |
{
|
|
|
79df40 |
MetaLegacyMonitorsConfig *legacy_config = key;
|
|
|
79df40 |
MetaMonitorConfigStore *config_store = user_data;
|
|
|
79df40 |
MetaMonitorManager *monitor_manager =
|
|
|
79df40 |
meta_monitor_config_store_get_monitor_manager (config_store);
|
|
|
79df40 |
+ g_autoptr (MetaMonitorsConfig) config = NULL;
|
|
|
79df40 |
GList *logical_monitor_configs;
|
|
|
79df40 |
MetaLogicalMonitorLayoutMode layout_mode;
|
|
|
79df40 |
GError *error = NULL;
|
|
|
79df40 |
GList *disabled_monitor_specs;
|
|
|
79df40 |
- MetaMonitorsConfig *config;
|
|
|
79df40 |
|
|
|
79df40 |
logical_monitor_configs = derive_logical_monitor_configs (legacy_config,
|
|
|
79df40 |
config_store,
|
|
|
79df40 |
&error);
|
|
|
79df40 |
if (!logical_monitor_configs)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_autofree char *config_name = NULL;
|
|
|
79df40 |
|
|
|
79df40 |
config_name = generate_config_name (legacy_config);
|
|
|
79df40 |
g_warning ("Failed to migrate monitor configuration for %s: %s",
|
|
|
79df40 |
config_name, error->message);
|
|
|
79df40 |
return;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
disabled_monitor_specs = find_disabled_monitor_specs (legacy_config);
|
|
|
79df40 |
|
|
|
79df40 |
layout_mode = META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
|
|
|
79df40 |
config = meta_monitors_config_new_full (logical_monitor_configs,
|
|
|
79df40 |
disabled_monitor_specs,
|
|
|
79df40 |
layout_mode,
|
|
|
79df40 |
META_MONITORS_CONFIG_FLAG_MIGRATED);
|
|
|
79df40 |
if (!meta_verify_monitors_config (config, monitor_manager, &error))
|
|
|
79df40 |
{
|
|
|
79df40 |
g_autofree char *config_name = NULL;
|
|
|
79df40 |
|
|
|
79df40 |
config_name = generate_config_name (legacy_config);
|
|
|
79df40 |
g_warning ("Ignoring invalid monitor configuration for %s: %s",
|
|
|
79df40 |
config_name, error->message);
|
|
|
79df40 |
- g_object_unref (config);
|
|
|
79df40 |
return;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
meta_monitor_config_store_add (config_store, config);
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
gboolean
|
|
|
79df40 |
meta_migrate_old_monitors_config (MetaMonitorConfigStore *config_store,
|
|
|
79df40 |
GFile *in_file,
|
|
|
79df40 |
GError **error)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_autoptr (GHashTable) configs = NULL;
|
|
|
79df40 |
|
|
|
79df40 |
configs = load_config_file (in_file, error);
|
|
|
79df40 |
if (!configs)
|
|
|
79df40 |
return FALSE;
|
|
|
79df40 |
|
|
|
79df40 |
g_hash_table_foreach (configs, migrate_config, config_store);
|
|
|
79df40 |
|
|
|
79df40 |
return TRUE;
|
|
|
79df40 |
}
|
|
|
79df40 |
|
|
|
79df40 |
gboolean
|
|
|
79df40 |
meta_migrate_old_user_monitors_config (MetaMonitorConfigStore *config_store,
|
|
|
79df40 |
GError **error)
|
|
|
79df40 |
{
|
|
|
79df40 |
g_autofree char *backup_path = NULL;
|
|
|
79df40 |
g_autoptr (GFile) backup_file = NULL;
|
|
|
79df40 |
g_autofree char *user_file_path = NULL;
|
|
|
79df40 |
g_autoptr (GFile) user_file = NULL;
|
|
|
79df40 |
--
|
|
|
79df40 |
2.26.2
|
|
|
79df40 |
|