Adding a schema key breaks schema installation?

I created a new project using Builder’s Vala template. I noticed that as soon as I add a key to the schema, the project fails to run with an error:

(process:2): GLib-GIO-ERROR **: 13:20:28.846: Settings schema 'org.gnome.gitlab.subpop.settingstest' is not installed

The commit that causes the error is quite small:

diff --git a/data/org.gnome.gitlab.subpop.settingstest.gschema.xml b/data/org.gnome.gitlab.subpop.settingstest.gschema.xml
index e0f76aafe24a8ef68ab02a094d974a8798e14ae3..96de5ceafd57837e30aee1d180834e15e1c4c757 100644
--- a/data/org.gnome.gitlab.subpop.settingstest.gschema.xml
+++ b/data/org.gnome.gitlab.subpop.settingstest.gschema.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <schemalist gettext-domain="settingstest">
 	<schema id="org.gnome.gitlab.subpop.settingstest" path="/org/gnome/gitlab/subpop/settingstest/">
+	  <key name="test" type="s"/>
diff --git a/src/application.vala b/src/application.vala
index eb29d320ccb81113ffe4860ec75d2a70ec629947..b95bedf869cc16ce9aec0c0f79226c96d61928a7 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -20,6 +20,7 @@
 namespace Settingstest {
     public class Application : Adw.Application {
+        public static Settings settings = new Settings ("org.gnome.gitlab.subpop.settingstest");
         public Application () {
             Object (application_id: "org.gnome.gitlab.subpop.settingstest", flags: ApplicationFlags.FLAGS_NONE);

By removing either one or the other of these lines, the program runs successfully. Is there something else I need to do to get a settings schema working? I uploaded a demo here: Link Dupont / settingstest · GitLab.

I figured it out. The XML schema must have a <default> element, and for strings, the value must be defined, even if just an empty string:

<key name="test" type="s">
1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.