Author: cazfi
Date: Wed Jan 27 01:52:08 2016
New Revision: 31619

URL: http://svn.gna.org/viewcvs/freeciv?rev=31619&view=rev
Log:
Cleanup and improve comments of gtk-clients' refresh_worklist()

Requested by Jacob Nevins <jtn>

See bug #17595

Modified:
    branches/S2_6/client/gui-gtk-2.0/wldlg.c
    branches/S2_6/client/gui-gtk-3.0/wldlg.c

Modified: branches/S2_6/client/gui-gtk-2.0/wldlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/wldlg.c?rev=31619&r1=31618&r2=31619&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/wldlg.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/wldlg.c    Wed Jan 27 01:52:08 2016
@@ -1329,7 +1329,6 @@
 void refresh_worklist(GtkWidget *editor)
 {
   struct worklist_data *ptr;
-  const struct global_worklist *pgwl = NULL;
   struct worklist queue;
   struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
   int i, targets_used;
@@ -1343,10 +1342,6 @@
 
   ptr = g_object_get_data(G_OBJECT(editor), "data");
 
-  if (!ptr->pcity
-      && !(pgwl = global_worklist_by_id(ptr->global_worklist_id))) {
-  }
-
   /* refresh source tasks. */
   if (gtk_tree_selection_get_selected(ptr->src_selection, NULL, &it)) {
     gtk_tree_model_get(GTK_TREE_MODEL(ptr->src), &it, 0, &id, -1);
@@ -1356,6 +1351,8 @@
   }
   gtk_list_store_clear(ptr->src);
 
+  /* These behave just right if ptr->pcity is NULL -> in case of global
+   * worklist. */
   targets_used = collect_eventually_buildable_targets(targets, ptr->pcity,
                                                       ptr->future);
   name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity);
@@ -1380,10 +1377,15 @@
   exists = gtk_tree_model_get_iter_first(model, &it);
 
   /* dance around worklist braindamage. */
-  if (ptr->pcity) {
+  if (ptr->pcity != NULL) {
     city_get_queue(ptr->pcity, &queue);
   } else {
+    const struct global_worklist *pgwl;
+
+    pgwl = global_worklist_by_id(ptr->global_worklist_id);
+
     fc_assert(NULL != pgwl);
+
     worklist_copy(&queue, global_worklist_get(pgwl));
   }
 
@@ -1416,8 +1418,8 @@
 
   /* update widget sensitivity. */
   if (ptr->pcity) {
-    if ((can_client_issue_orders() &&
-        city_owner(ptr->pcity) == client.conn.playing)) {
+    if ((can_client_issue_orders()
+         && city_owner(ptr->pcity) == client.conn.playing)) {
       gtk_widget_set_sensitive(ptr->add_cmd, TRUE);
       gtk_widget_set_sensitive(ptr->dst_view, TRUE);
     } else {

Modified: branches/S2_6/client/gui-gtk-3.0/wldlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/wldlg.c?rev=31619&r1=31618&r2=31619&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/wldlg.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/wldlg.c    Wed Jan 27 01:52:08 2016
@@ -1334,7 +1334,6 @@
 void refresh_worklist(GtkWidget *editor)
 {
   struct worklist_data *ptr;
-  const struct global_worklist *pgwl = NULL;
   struct worklist queue;
   struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
   int i, targets_used;
@@ -1348,10 +1347,6 @@
 
   ptr = g_object_get_data(G_OBJECT(editor), "data");
 
-  if (!ptr->pcity
-      && !(pgwl = global_worklist_by_id(ptr->global_worklist_id))) {
-  }
-
   /* refresh source tasks. */
   if (gtk_tree_selection_get_selected(ptr->src_selection, NULL, &it)) {
     gtk_tree_model_get(GTK_TREE_MODEL(ptr->src), &it, 0, &id, -1);
@@ -1361,6 +1356,8 @@
   }
   gtk_list_store_clear(ptr->src);
 
+  /* These behave just right if ptr->pcity is NULL -> in case of global
+   * worklist. */
   targets_used = collect_eventually_buildable_targets(targets, ptr->pcity,
                                                       ptr->future);
   name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity);
@@ -1385,10 +1382,15 @@
   exists = gtk_tree_model_get_iter_first(model, &it);
 
   /* dance around worklist braindamage. */
-  if (ptr->pcity) {
+  if (ptr->pcity != NULL) {
     city_get_queue(ptr->pcity, &queue);
   } else {
+    const struct global_worklist *pgwl;
+
+    pgwl = global_worklist_by_id(ptr->global_worklist_id);
+
     fc_assert(NULL != pgwl);
+
     worklist_copy(&queue, global_worklist_get(pgwl));
   }
 
@@ -1421,8 +1423,8 @@
 
   /* update widget sensitivity. */
   if (ptr->pcity) {
-    if ((can_client_issue_orders() &&
-        city_owner(ptr->pcity) == client.conn.playing)) {
+    if ((can_client_issue_orders()
+         && city_owner(ptr->pcity) == client.conn.playing)) {
       gtk_widget_set_sensitive(ptr->add_cmd, TRUE);
       gtk_widget_set_sensitive(ptr->dst_view, TRUE);
     } else {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to