<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39364 >

The problem was not in the translation routines.  It had other causes.

This code has *never* worked: PR#14243 committed in revision 11100 (Sun,
09 Oct 2005) 20 months ago.

The primary cause is that code freed the section file data before copying
the name and description strings.  Their pointers were no longer valid.

The secondary problem is that the new routine section_file_load_section,
used only in this place, did not function as documented.  (PR#39396)

Although my patch works, it has not been tested extensively.  It is
dependent on other patches to function properly, and should be
committed simultaneously.

This patch also fixes a minor error from PR#14243, where two patches
added the same information to different sections of tutorial.sav.

Index: client/gui-gtk-2.0/pages.c
===================================================================
--- client/gui-gtk-2.0/pages.c  (revision 12991)
+++ client/gui-gtk-2.0/pages.c  (working copy)
@@ -1825,23 +1825,28 @@
   datafile_list_iterate(files, pfile) {
     GtkTreeIter it;
     struct section_file sf;
-    char *description = NULL, *name = NULL;
 
+    gtk_list_store_append(scenario_store, &it);
+
     if (section_file_load_section(&sf, pfile->fullname, "scenario")) {
-      name = secfile_lookup_str_default(&sf, NULL, "scenario.name");
-      description = secfile_lookup_str_default(&sf,
+      char *sname = secfile_lookup_str_default(&sf, NULL, "scenario.name");
+      char *sdescription = secfile_lookup_str_default(&sf,
                                               NULL, "scenario.description");
+
+      gtk_list_store_set(scenario_store, &it,
+                        0, sname ? Q_(sname) : pfile->name,
+                        1, pfile->fullname,
+                        2, sdescription ? Q_(sdescription) : "",
+                       -1);
       section_file_free(&sf);
+    } else {
+      gtk_list_store_set(scenario_store, &it,
+                        0, pfile->name,
+                        1, pfile->fullname,
+                        2, "",
+                       -1);
     }
 
-    /* Translated loaded names (if any). */
-    name = name ? _(name) : pfile->name;
-    description = description ? _(description) : "";
-
-    gtk_list_store_append(scenario_store, &it);
-    gtk_list_store_set(scenario_store, &it,
-                      0, name, 1, pfile->fullname, 2, description, -1);
-
     free(pfile->name);
     free(pfile->fullname);
     free(pfile);
Index: data/scenario/tutorial.sav
===================================================================
--- data/scenario/tutorial.sav  (revision 12991)
+++ data/scenario/tutorial.sav  (working copy)
@@ -455,7 +455,6 @@
 randseed=0
 save_random=0
 rulesetdir="default"
-description="Tutorial Scenario."
 
 [savefile]
 options="startoptions spacerace2 rulesets diplchance_percent worklists2 
map_editor known32fix turn attributes watchtower rulesetdir client_worklists 
orders startunits turn_last_built improvement_order technology_order embassies"
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to