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.
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);
 }

Attachment: pgpcQqoZnILfn.pgp
Description: PGP signature

_______________________________________________
balsa-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/balsa-list

Reply via email to