[Bug+Fix] g_assert_not_reached() triggerd after running init wizard
Albrecht Dreß <[email protected]> Wed, 17 Apr 2019 19:31:12 +0200
| Newsgroups | gmane.comp.gnome.apps.balsa |
|---|---|
| Message-ID | <[email protected]> |
Hi all, when running Balsa for the first time, after successfully running the wizard, Balsa ejects with ERROR:geometry-manager.c:63:geometry_manager_init: code should not be reached Reason: When I wrote the geometry manager, I did not realise that config_global_load() may actually be called multiple times (from config_init()) when Balsa has not yet been configured. Thus, the g_assert_not_reached() (which I inserted to detect multiple definitions of the same key) is plain wrong. The attached patch fixes the issue. Note that I use a single-entry-single-exit solution here which is usually be considered as safer as the function uses a lock which may easily be forgotten to unlock… If you feel this is over-engineered, the g_assert_not_reached() could also just be replaced by “G_UNLOCK(geometry_hash);return;”. Cheers, Albrecht. _______________________________________________ balsa-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/balsa-list
fix-wizard-assert.diff
(text/x-patch, 1.8 KB)
diff --git a/libbalsa/geometry-manager.c b/libbalsa/geometry-manager.c
index a1c8ade68..83bbfb5b2 100644
--- a/libbalsa/geometry-manager.c
+++ b/libbalsa/geometry-manager.c
@@ -47,7 +47,6 @@ static void notify_is_maximized_cb(GtkWindow *window,
void
geometry_manager_init(const gchar *key, gint width, gint height, gboolean maximized)
{
- geometry_t *size_item;
gchar *config_key;
g_return_if_fail((key != NULL) && (key[0] != '\0') && (width > 0) && (height > 0));
@@ -59,24 +58,24 @@ geometry_manager_init(const gchar *key, gint width, gint height, gboolean maximi
atexit(geometry_manager_destroy);
}
- if (g_hash_table_contains(geometry_hash, key)) {
- g_assert_not_reached(); /* programming error: key must be unique */
- } else {
+ if (!g_hash_table_contains(geometry_hash, key)) {
+ geometry_t *size_item;
+
size_item = g_new0(geometry_t, 1);
g_hash_table_insert(geometry_hash, g_strdup(key), size_item);
- }
- config_key = g_strdup_printf("%sWidth=%d", key, width);
- size_item->width = libbalsa_conf_get_int(config_key);
- g_free(config_key);
+ config_key = g_strdup_printf("%sWidth=%d", key, width);
+ size_item->width = libbalsa_conf_get_int(config_key);
+ g_free(config_key);
- config_key = g_strdup_printf("%sHeight=%d", key, height);
- size_item->height = libbalsa_conf_get_int(config_key);
- g_free(config_key);
+ config_key = g_strdup_printf("%sHeight=%d", key, height);
+ size_item->height = libbalsa_conf_get_int(config_key);
+ g_free(config_key);
- config_key = g_strdup_printf("%sMaximized=%s", key, maximized ? "true" : "false");
- size_item->maximized = libbalsa_conf_get_bool(config_key);
- g_free(config_key);
+ config_key = g_strdup_printf("%sMaximized=%s", key, maximized ? "true" : "false");
+ size_item->maximized = libbalsa_conf_get_bool(config_key);
+ g_free(config_key);
+ }
G_UNLOCK(geometry_hash);
}
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEcCEPemLFTtyGf4zATKlvDmfn2fgFAly3YuAACgkQTKlvDmfn 2fhjMAf/YzitzzdGmgTlSOaUdBdMIikldr8/LnAzp3RWCR+2JGbwFJPtejta/1V5 LImY0ILyg2GeznAPaUnq6SF0+Az7MEi8bojmv8VEMm2gNfcPzrPXZ+pzv7f8xe2y cBTImjh5Hj9JIPJO/t9q+nd7q9x4jqAUf2X4aoxhIQrtBVE5apOLYszraPctDppn NbyUTUS93dL0TMHvbY/AAYEZreezq0Gb/chiTiSVn6x9GY8pr37FhHFc7hDa3QBw IebQdufOmpSb7EyXHuwWvjQW+ZMlvmYoV3idB3z6OWyMB8a5KBLz58IprbAFouI3 InQlu1UpdjRslQIpDR4sO1E37oSO7Q== =Pxpu -----END PGP SIGNATURE-----