summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@igalia.com>2019-06-18 16:15:03 -0500
committerJan-Michael Brummer <jan.brummer@tabos.org>2019-06-19 18:52:16 +0000
commit53724537137c593076e9ca58add46387babdf16b (patch)
treeb0312ddb443f88c1d8cb8359b88afc0ef1921da9
parentbd597f5804e7e35c1aca1bec988ea97e4d8b5c8a (diff)
downloadepiphany-53724537137c593076e9ca58add46387babdf16b.tar.gz
Broken web apps should crash in a nicer way
Although #713 is fixed for new users, anyone who previously suffered from a broken web app migration is doomed to eternal crashes. We probably can't reasonably recover the broken profile dir, but we should at least try to warn users what is going on.
-rw-r--r--lib/ephy-settings.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/ephy-settings.c b/lib/ephy-settings.c
index 5ddd866e3..b5983f8c9 100644
--- a/lib/ephy-settings.c
+++ b/lib/ephy-settings.c
@@ -89,15 +89,37 @@ ephy_settings_get (const char *schema)
ephy_settings_init ();
gsettings = g_hash_table_lookup (settings, schema);
-
- if (gsettings == NULL) {
- gsettings = g_settings_new (schema);
- if (gsettings == NULL)
- g_warning ("Invalid schema %s requested", schema);
- else
- g_hash_table_insert (settings, g_strdup (schema), gsettings);
+ if (gsettings)
+ return gsettings;
+
+ if (strcmp (schema, EPHY_PREFS_WEB_APP_SCHEMA) == 0) {
+ /* EPHY_PREFS_WEB_APP_SCHEMA won't be added to the settings table if the
+ * ephy_profile_dir_is_web_application() is FALSE. But we can still get
+ * here in EPHY_EMBED_SHELL_MODE_APPLICATION if the profile dir is broken
+ * such that its .app file is missing. This includes any web apps created by
+ * Epiphany 3.30 or earlier that were migrated to 3.32 before 3.32.3 before
+ * the main profile migration. This generally means anybody using Epiphany
+ * only for web apps has wound up with broken web apps after the migration.
+ *
+ * We can only crash, but it's nicer to crash here rather than crash later.
+ *
+ * https://gitlab.gnome.org/GNOME/epiphany/issues/713
+ */
+ g_error ("Epiphany is trying to access web app settings outside web app"
+ " mode. Your web app may be broken. If so, you must delete it and"
+ " recreate. See epiphany#713.");
}
+ /* schema must not be relocatable, or g_settings_new() will crash. */
+ for (guint i = 0; i < G_N_ELEMENTS (ephy_prefs_relocatable_schemas); i++)
+ g_assert (strcmp (schema, ephy_prefs_relocatable_schemas[i].schema) != 0);
+
+ gsettings = g_settings_new (schema);
+ if (gsettings == NULL)
+ g_warning ("Invalid schema %s requested", schema);
+ else
+ g_hash_table_insert (settings, g_strdup (schema), gsettings);
+
return gsettings;
}