Author: mir3x
Date: Sun Dec 21 20:24:12 2014
New Revision: 27371

URL: http://svn.gna.org/viewcvs/freeciv?rev=27371&view=rev
Log:
Fixed dialog science refresh in qt-client when changing tileset

See bug #22935


Modified:
    trunk/client/gui-qt/fc_client.cpp
    trunk/client/gui-qt/mapview.cpp
    trunk/client/gui-qt/repodlgs.cpp
    trunk/client/gui-qt/repodlgs.h

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=27371&r1=27370&r2=27371&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Sun Dec 21 20:24:12 2014
@@ -590,7 +590,10 @@
 ****************************************************************************/
 void fc_client::remove_repo_dlg(QString str)
 {
-  opened_repo_dlgs.remove(str);
+  /* if app is closing opened_repo_dlg is already deleted */
+  if (is_closing() == false) {
+    opened_repo_dlgs.remove(str);
+  }
 }
 
 /****************************************************************************

Modified: trunk/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapview.cpp?rev=27371&r1=27370&r2=27371&view=diff
==============================================================================
--- trunk/client/gui-qt/mapview.cpp     (original)
+++ trunk/client/gui-qt/mapview.cpp     Sun Dec 21 20:24:12 2014
@@ -31,6 +31,7 @@
 #include "mapctrl_common.h"
 #include "overview_common.h"
 #include "sprite.h"
+#include "repodlgs.h"
 #include "text.h"
 
 // gui-qt
@@ -1467,8 +1468,22 @@
 ****************************************************************************/
 void tileset_changed(void)
 {
+  int i;
+  science_report *sci_rep;
+  QWidget *w;
+
   gui()->unitinfo_wdg->update_arrow_pix();
   destroy_city_dialog();
+  /* Update science report if open */
+  if (gui()->is_repo_dlg_open("SCI")) {
+    i = gui()->gimme_index_of("SCI");
+    fc_assert(i != -1);
+    w = gui()->game_tab_widget->widget(i);
+    sci_rep = reinterpret_cast<science_report*>(w);
+    sci_rep->reset_tree();
+    sci_rep->update_report();
+    sci_rep->repaint();
+  }
 }
 
 /****************************************************************************

Modified: trunk/client/gui-qt/repodlgs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/repodlgs.cpp?rev=27371&r1=27370&r2=27371&view=diff
==============================================================================
--- trunk/client/gui-qt/repodlgs.cpp    (original)
+++ trunk/client/gui-qt/repodlgs.cpp    Sun Dec 21 20:24:12 2014
@@ -53,31 +53,48 @@
 ****************************************************************************/
 research_diagram::research_diagram(QWidget *parent): QWidget(parent)
 {
+  pcanvas = NULL;
+  req = NULL;
+  reset();
+}
+
+/****************************************************************************
+  Destructor for research diagram
+****************************************************************************/
+research_diagram::~research_diagram()
+{
+  qtg_canvas_free(pcanvas);
+  destroy_reqtree(req);
+}
+
+/****************************************************************************
+  Recreates whole diagram and schedules update
+****************************************************************************/
+void research_diagram::update_reqtree()
+{
+  destroy_reqtree(req);
+  req = create_reqtree(client_player(), true);
+  draw_reqtree(req, pcanvas, 0, 0, 0, 0, width, height);
+  update();
+}
+
+/****************************************************************************
+  Initializes research diagram
+****************************************************************************/
+void research_diagram::reset()
+{
+  if (req != NULL) {
+    destroy_reqtree(req);
+  }
+  if (pcanvas != NULL) {
+    qtg_canvas_free(pcanvas);
+  }
   req = create_reqtree(client_player(), true);
   get_reqtree_dimensions(req, &width, &height);
   pcanvas = qtg_canvas_create(width, height);
   pcanvas->map_pixmap.fill(Qt::transparent);
 }
 
-/****************************************************************************
-  Destructor for research diagram
-****************************************************************************/
-research_diagram::~research_diagram()
-{
-  qtg_canvas_free(pcanvas);
-  destroy_reqtree(req);
-}
-
-/****************************************************************************
-  Recreates whole diagram and schedules update
-****************************************************************************/
-void research_diagram::update_reqtree()
-{
-  destroy_reqtree(req);
-  req = create_reqtree(client_player(), true);
-  draw_reqtree(req, pcanvas, 0, 0, 0, 0, width, height);
-  update();
-}
 
 /****************************************************************************
   Mouse handler for research_diagram
@@ -207,6 +224,18 @@
 ****************************************************************************/
 void science_report::redraw()
 {
+  update();
+}
+
+/****************************************************************************
+  Recalculates research diagram again and updates science report
+****************************************************************************/
+void science_report::reset_tree()
+{
+  QSize size;
+  res_diag->reset();
+  size = res_diag->size();
+  res_diag->setMinimumSize(size);
   update();
 }
 

Modified: trunk/client/gui-qt/repodlgs.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/repodlgs.h?rev=27371&r1=27370&r2=27371&view=diff
==============================================================================
--- trunk/client/gui-qt/repodlgs.h      (original)
+++ trunk/client/gui-qt/repodlgs.h      Sun Dec 21 20:24:12 2014
@@ -60,6 +60,7 @@
   research_diagram(QWidget *parent = 0);
   ~research_diagram();
   void update_reqtree();
+  void reset();
   QSize size();
 
 private:
@@ -97,6 +98,7 @@
   void update_report();
   void init(bool raise);
   void redraw();
+  void reset_tree();
 
 private:
   void update_reqtree();


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

Reply via email to