Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2000:
[Freeciv-Dev] Re: fix Gtk+ City Report; was Re: two bugs (PR#259)
Home

[Freeciv-Dev] Re: fix Gtk+ City Report; was Re: two bugs (PR#259)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: fix Gtk+ City Report; was Re: two bugs (PR#259)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sun, 20 Feb 2000 13:07:07 +1100 (EST)

David Pfitzner wrote:

> The reaon is that when a city dialog is popped up, it
> automatically calls city_report_dialog_update_city()
> -- ie, update the city report in case the city has changed.
...
> For the Xaw client this often does nothing or almost nothing,
> but for the Gtk+ client it always (? or mostly) removes
> the entry and then adds it back.

This suggests that a solution would be to avoid doing
the remove/putback thing.  This patch tries to do this,
by instead updating the row in-place.

Seems to work ok...  I can no longer reproduce the crashes
and/or display/memory garbage problems, and haven't noticed
any other problems.

-- David

--- fc-adv/client/gui-gtk/cityrep.c     Fri Feb 11 17:58:29 2000
+++ freeciv-cvs/client/gui-gtk/cityrep.c        Sun Feb 20 12:56:27 2000
@@ -1187,6 +1187,25 @@
   }
 
   if((i=gtk_clist_find_row_from_data(GTK_CLIST(city_list), pcity))!=-1)  {
+#if 1
+    /* This method avoids removing and re-adding the entry, because
+       that seemed to cause problems in some cases, when the list
+       is sorted by one of the columns.  Doing "Popup" for the top
+       entry when sorted could cause core dumps or memory corruption,
+       and in other cases could change the ordering (confusing) when
+       multiple cities have the same string value in the column being
+       sorted by.  -- dwp
+    */
+    int j;
+    get_city_text(pcity, row, sizeof(buf[0]));
+    gtk_clist_freeze(GTK_CLIST(city_list));
+    for (j=0; j<NUM_CREPORT_COLS; j++) {
+      gtk_clist_set_text(GTK_CLIST(city_list), i, j, row[j]);
+    }
+    gtk_clist_thaw(GTK_CLIST(city_list));
+    gtk_widget_show_all(city_list);
+#else
+    /* Old method, see above. */
     char *text;
     gboolean selected = (gboolean) g_list_find(GTK_CLIST(city_list)->selection,
                                               (gpointer)i);
@@ -1203,6 +1222,7 @@
       gtk_clist_select_row(GTK_CLIST(city_list), i, -1);
     gtk_clist_thaw(GTK_CLIST(city_list));
     gtk_widget_show_all(city_list);
+#endif
   }
   else
     city_report_dialog_update();

[Prev in Thread] Current Thread [Next in Thread]