Author: cazfi
Date: Wed Jul 29 02:07:31 2015
New Revision: 29262

URL: http://svn.gna.org/viewcvs/freeciv?rev=29262&view=rev
Log:
Fixed Qt-client crash when Meeting begins and player is under AI control.

Reported by Christian Montanari <ptizoom>

See bug #23626

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

Modified: branches/S2_5/client/gui-qt/diplodlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/diplodlg.cpp?rev=29262&r1=29261&r2=29262&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/diplodlg.cpp    (original)
+++ branches/S2_5/client/gui-qt/diplodlg.cpp    Wed Jul 29 02:07:31 2015
@@ -165,7 +165,6 @@
   layout->addWidget(cancel_treaty, 17, 6);
   setLayout(layout);
   update_wdg();
-
 }
 
 /****************************************************************************
@@ -695,13 +694,13 @@
 /****************************************************************************
   Initializes some data for diplomacy dialog
 ****************************************************************************/
-void diplo_dlg::init(bool raise)
+bool diplo_dlg::init(bool raise)
 {
   if (!can_client_issue_orders()) {
-    return;
+    return false;
   }
   if (client.conn.playing->ai_controlled) {
-    return;
+    return false;
   }
   setAttribute(Qt::WA_DeleteOnClose);
   gui()->gimme_place(this, "DDI");
@@ -712,6 +711,8 @@
   } else {
     gui()->game_tab_widget->setCurrentIndex(index);
   }
+
+  return true;
 }
 /****************************************************************************
   Destructor for diplomacy dialog
@@ -721,12 +722,12 @@
   QMapIterator<int, diplo_wdg *>i(treaty_list);
   diplo_wdg *dw;
 
-   while (i.hasNext()) {
-     i.next();
-      dw = i.value();
-      removeTab(dw->get_index());
-      dw->deleteLater();
-   }
+  while (i.hasNext()) {
+    i.next();
+    dw = i.value();
+    removeTab(dw->get_index());
+    dw->deleteLater();
+  }
   gui()->remove_repo_dlg("DDI");
 }
 
@@ -811,7 +812,11 @@
   }
   if (!gui()->is_repo_dlg_open("DDI")) {
     diplo_dlg *dd = new diplo_dlg(counterpart, initiated_from);
-    dd->init(false);
+
+    if (!dd->init(false)) {
+      delete dd;
+      return;
+    }
     dd->update_dlg();
     dd->make_active(counterpart);
   }

Modified: branches/S2_5/client/gui-qt/diplodlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/diplodlg.h?rev=29262&r1=29261&r2=29262&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/diplodlg.h      (original)
+++ branches/S2_5/client/gui-qt/diplodlg.h      Wed Jul 29 02:07:31 2015
@@ -107,7 +107,7 @@
   diplo_dlg(int counterpart, int initiated_from);
   ~diplo_dlg();
   void update_dlg();
-  void init(bool raise);
+  bool init(bool raise);
   diplo_wdg *find_widget(int counterpart);
   void close_widget(int counterpart);
   void add_widget(int counterpart, int initiated_from);

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=29262&r1=29261&r2=29262&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_5/client/gui-qt/fc_client.cpp   Wed Jul 29 02:07:31 2015
@@ -493,15 +493,16 @@
 /****************************************************************************
   Finds not used index on game_view_tab and returns it
 ****************************************************************************/
-void fc_client::gimme_place(QWidget* widget, QString str)
+void fc_client::gimme_place(QWidget *widget, QString str)
 {
   QString x;
+
   x = opened_repo_dlgs.key(widget);
 
-      if (x.isEmpty()) {
-        opened_repo_dlgs.insert(str, widget);
-        return;
-    }
+  if (x.isEmpty()) {
+    opened_repo_dlgs.insert(str, widget);
+    return;
+  }
   log_error("Failed to find place for new tab widget");
   return;
 }


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

Reply via email to