[gnome-terminal/gnome-43] client: Use verified schema



commit b19b82be2b6d4a6a45f654bede864629d3247abe
Author: Christian Persch <chpe src gnome org>
Date:   Sun Sep 18 19:19:27 2022 +0200

    client: Use verified schema
    
    ... and pass the correct schema source when creating the profile list.
    
    (cherry picked from commit 640f2078656d953f661cef2f8ea4f3539cdb7d4d)
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7930

 src/terminal-options.cc        | 25 +++++++++++++++++++++----
 src/terminal-options.hh        |  2 ++
 src/terminal-settings-list.cc  |  4 +---
 src/terminal-settings-utils.cc |  8 ++++++--
 src/terminal-settings-utils.hh |  1 -
 5 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/src/terminal-options.cc b/src/terminal-options.cc
index e2e562dc..9e672f5d 100644
--- a/src/terminal-options.cc
+++ b/src/terminal-options.cc
@@ -38,6 +38,7 @@
 #include "terminal-util.hh"
 #include "terminal-version.hh"
 #include "terminal-libgsystem.hh"
+#include "terminal-settings-utils.hh"
 
 static int verbosity = 1;
 
@@ -107,11 +108,23 @@ terminal_log_writer (GLogLevelFlags log_level,
 
 static GOptionContext *get_goption_context (TerminalOptions *options);
 
+static void
+terminal_options_ensure_schema_source(TerminalOptions* options)
+{
+  if (options->schema_source)
+    return;
+
+  options->schema_source = terminal_g_settings_schema_source_get_default();
+}
+
 static TerminalSettingsList *
 terminal_options_ensure_profiles_list (TerminalOptions *options)
 {
-  if (options->profiles_list == nullptr)
-    options->profiles_list = terminal_profiles_list_new(nullptr, nullptr);
+  if (options->profiles_list == nullptr) {
+    terminal_options_ensure_schema_source(options);
+    options->profiles_list = terminal_profiles_list_new(nullptr /* default backend */,
+                                                        options->schema_source);
+  }
 
   return options->profiles_list;
 }
@@ -1264,8 +1277,11 @@ terminal_options_merge_config (TerminalOptions *options,
 void
 terminal_options_ensure_window (TerminalOptions *options)
 {
-  gs_unref_object GSettings *global_settings =
-    g_settings_new (TERMINAL_SETTING_SCHEMA);
+  terminal_options_ensure_schema_source(options);
+  gs_unref_object auto global_settings =
+    terminal_g_settings_new(nullptr, // default backend
+                            options->schema_source,
+                            TERMINAL_SETTING_SCHEMA);
 
   gs_free char *mode_str = g_settings_get_string (global_settings,
                                                   TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY);
@@ -1304,6 +1320,7 @@ terminal_options_free (TerminalOptions *options)
   g_free (options->sm_config_prefix);
 
   g_clear_object (&options->profiles_list);
+  g_clear_pointer (&options->schema_source, g_settings_schema_source_unref);
 
   g_free (options);
 }
diff --git a/src/terminal-options.hh b/src/terminal-options.hh
index 60adebb3..fe88361f 100644
--- a/src/terminal-options.hh
+++ b/src/terminal-options.hh
@@ -25,6 +25,7 @@
 #include <glib.h>
 #include <stdio.h>
 
+#include <gio/gio.h>
 #include <gio/gunixfdlist.h>
 
 #include "terminal-profiles-list.hh"
@@ -63,6 +64,7 @@ enum
 
 typedef struct
 {
+  GSettingsSchemaSource* schema_source; /* may be nullptr */
   TerminalSettingsList *profiles_list; /* may be nullptr */
 
   gboolean print_environment;
diff --git a/src/terminal-settings-list.cc b/src/terminal-settings-list.cc
index 40b9a985..f0db40d1 100644
--- a/src/terminal-settings-list.cc
+++ b/src/terminal-settings-list.cc
@@ -468,9 +468,7 @@ terminal_settings_list_constructed (GObject *object)
 
   g_object_get(object, "backend", &list->settings_backend, nullptr);
   g_assert(list->settings_backend);
-
-  if (list->schema_source == nullptr)
-    list->schema_source = g_settings_schema_source_get_default();
+  g_assert(list->schema_source);
 
   g_assert (list->schema_source != nullptr);
   g_assert (list->child_schema_id != nullptr);
diff --git a/src/terminal-settings-utils.cc b/src/terminal-settings-utils.cc
index 60e7a9ae..494a257e 100644
--- a/src/terminal-settings-utils.cc
+++ b/src/terminal-settings-utils.cc
@@ -18,6 +18,8 @@
 #include "config.h"
 #define G_SETTINGS_ENABLE_BACKEND
 
+#include <gio/gsettingsbackend.h>
+
 #include "terminal-settings-utils.hh"
 #include "terminal-client-utils.hh"
 #include "terminal-debug.hh"
@@ -217,6 +219,8 @@ terminal_g_settings_backend_erase_path(GSettingsBackend* backend,
   return r;
 }
 
+#endif /* TERMINAL_SERVER || TERMINAL_PREFERENCES */
+
 #define TERMINAL_SCHEMA_VERIFIER_ERROR (g_quark_from_static_string("TerminalSchemaVerifier"))
 
 typedef enum {
@@ -558,6 +562,8 @@ terminal_g_settings_schema_source_get_default(void)
                                               TERM_LIBEXECDIR,
 #elif defined(TERMINAL_PREFERENCES)
                                               TERM_LIBEXECDIR,
+#elif defined(TERMINAL_CLIENT)
+                                              TERM_BINDIR,
 #else
 #error Need to define installed location
 #endif
@@ -593,8 +599,6 @@ terminal_g_settings_schema_source_get_default(void)
   return g_settings_schema_source_ref(default_source);
 }
 
-#endif /* TERMINAL_SERVER || TERMINAL_PREFERENCES */
-
 // BEGIN copied from glib/gio/gsettingsbackend.c
 
 /*
diff --git a/src/terminal-settings-utils.hh b/src/terminal-settings-utils.hh
index 9079485e..8a200424 100644
--- a/src/terminal-settings-utils.hh
+++ b/src/terminal-settings-utils.hh
@@ -18,7 +18,6 @@
 #pragma once
 
 #include <gio/gio.h>
-#include <gio/gsettingsbackend.h>
 
 GSettings* terminal_g_settings_new (GSettingsBackend* backend,
                                     GSettingsSchemaSource* source,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]