Author: mir3x
Date: Sun Dec 20 19:49:16 2015
New Revision: 31112

URL: http://svn.gna.org/viewcvs/freeciv?rev=31112&view=rev
Log:
Changed updating info_label behaviour, it waits about 100 msecs,
and if no new updates comes, then calls update_info_label().

See bug #24153


Modified:
    branches/S2_5/client/gui-qt/fc_client.cpp
    branches/S2_5/client/gui-qt/fc_client.h
    branches/S2_5/client/gui-qt/mapview.cpp

Modified: branches/S2_5/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.cpp?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_5/client/gui-qt/fc_client.cpp   Sun Dec 20 19:49:16 2015
@@ -103,6 +103,7 @@
   pre_vote = NULL;
   x_vote = NULL;
   gtd = NULL;
+  update_info_timer = nullptr;
   for (int i = 0; i <= PAGE_GGZ; i++) {
     pages_layout[i] = NULL;
     pages[i] = NULL;

Modified: branches/S2_5/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.h?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.h     (original)
+++ branches/S2_5/client/gui-qt/fc_client.h     Sun Dec 20 19:49:16 2015
@@ -172,6 +172,7 @@
 
   QTimer* meta_scan_timer;
   QTimer* lan_scan_timer;
+  QTimer *update_info_timer;
 
   QStatusBar *status_bar;
   QSignalMapper *switch_page_mapper;
@@ -266,6 +267,7 @@
 public slots:
   void switch_page(int i);
   void popup_client_options();
+  void update_info_label();
 
 protected slots:
 

Modified: branches/S2_5/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/mapview.cpp?rev=31112&r1=31111&r2=31112&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/mapview.cpp     (original)
+++ branches/S2_5/client/gui-qt/mapview.cpp     Sun Dec 20 19:49:16 2015
@@ -1297,14 +1297,35 @@
 ****************************************************************************/
 void update_info_label(void)
 {
+  gui()->update_info_label();
+}
+
+/****************************************************************************
+  Real update, updates only once per 100 ms.
+****************************************************************************/
+void fc_client::update_info_label(void)
+{
   QString s, eco_info;
 
-  if (gui()->current_page() != PAGE_GAME) {
+  if (current_page() != PAGE_GAME) {
     return;
   }
+  if (update_info_timer == nullptr) {
+    update_info_timer = new QTimer();
+    update_info_timer->setSingleShot(true);
+    connect(update_info_timer, SIGNAL(timeout()),
+            this, SLOT(update_info_label()));
+    update_info_timer->start(100);
+    return;
+  }
+
+  if (update_info_timer->remainingTime() > 0) {
+    return;
+  }
+
   s = QString(_("%1 (Turn:%2)")).arg(textyear(game.info.year),
                                      QString::number(game.info.turn));
-  gui()->game_info_label->set_turn_info(s);
+  game_info_label->set_turn_info(s);
   set_indicator_icons(client_research_sprite(),
                       client_warming_sprite(),
                       client_cooling_sprite(), client_government_sprite());
@@ -1318,11 +1339,14 @@
            .arg(QString::number(client.conn.playing->economic.gold),
            QString::number(player_get_expected_income(client.conn.playing)));
     }
-    gui()->game_info_label->set_eco_info(eco_info);
-  }
-  gui()->game_info_label->info_update();
-  gui()->end_turn_rect->end_turn_update();
-}
+    game_info_label->set_eco_info(eco_info);
+  }
+  game_info_label->info_update();
+  end_turn_rect->end_turn_update();
+  delete update_info_timer;
+  update_info_timer = nullptr;
+}
+
 
 /****************************************************************************
   Update the information label which gives info on the current unit


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

Reply via email to