[gnome-control-center/wip/jtojnar/region-fixes: 12/12] region: Fix critical when changing language




commit c9448f76c2638ca72cd4f144c3a154ab05104e0a
Author: Jan Tojnar <jtojnar gmail com>
Date:   Fri May 20 02:20:11 2022 +0200

    region: Fix critical when changing language
    
    Changing user’s language resets the formats (region) by passing `NULL` to `update_region`.
    However, updating the region calls `maybe_notify`, whose callback `maybe_notify_finish`
    tries to parse the `mnd->target_locale` (the `NULL`), producing a critical:
    
        GLib-CRITICAL **: g_regex_match_full: assertion 'string != NULL' failed
    
    Since updating the language itself already triggers the notification check,
    let’s just skip calling `maybe_notify` here in that case.

 panels/region/cc-region-panel.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 337d7d4b7..590be1929 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -329,6 +329,13 @@ update_region (CcRegionPanel  *self,
                         g_settings_set_string (self->locale_settings, KEY_REGION, region);
                 if (self->login_auto_apply)
                         set_system_region (self, region);
+
+                if (region == NULL || region[0] == '\0') {
+                        // Formats (region) are being reset as part of changing the language,
+                        // and that already triggers the notification check.
+                        return;
+                }
+
                 maybe_notify (self, LC_TIME, region);
                 break;
 


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