Author: mir3x
Date: Mon Nov 16 19:52:59 2015
New Revision: 30630

URL: http://svn.gna.org/viewcvs/freeciv?rev=30630&view=rev
Log:
Fixed modal menu in city dialog and some message boxes,
which could crash qt client (their parent object could
be destroyed, and then modal menu/messagebox would crash)  

See bug #24047


Modified:
    branches/S2_6/client/gui-qt/citydlg.cpp
    branches/S2_6/client/gui-qt/citydlg.h

Modified: branches/S2_6/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.cpp?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/citydlg.cpp     (original)
+++ branches/S2_6/client/gui-qt/citydlg.cpp     Mon Nov 16 19:52:59 2015
@@ -129,7 +129,7 @@
 ****************************************************************************/
 void unit_item::contextMenuEvent(QContextMenuEvent *event)
 {
-  QMenu menu(this);
+  QMenu *menu = new QMenu(this);
 
   if (!can_client_issue_orders()) {
     return;
@@ -137,33 +137,33 @@
   if (unit_owner(qunit) != client_player()) {
     return;
   }
-  menu.addAction(activate);
-  menu.addAction(activate_and_close);
+  menu->addAction(activate);
+  menu->addAction(activate_and_close);
   if (sentry) {
-    menu.addAction(sentry);
+    menu->addAction(sentry);
   }
   if (fortify) {
-    menu.addAction(fortify);
+    menu->addAction(fortify);
   }
   if (change_home) {
-    menu.addAction(change_home);
+    menu->addAction(change_home);
   }
   if (load) {
-    menu.addAction(load);
+    menu->addAction(load);
   }
   if (unload) {
-    menu.addAction(unload);
+    menu->addAction(unload);
   }
   if (unload_trans) {
-    menu.addAction(unload_trans);
+    menu->addAction(unload_trans);
   }
   if (disband_action) {
-    menu.addAction(disband_action);
+    menu->addAction(disband_action);
   }
   if (upgrade) {
-    menu.addAction(upgrade);
-  }
-  menu.exec(event->globalPos());
+    menu->addAction(upgrade);
+  }
+  menu->popup(event->globalPos());
 }
 
 /****************************************************************************
@@ -237,7 +237,7 @@
 ****************************************************************************/
 void unit_item::disband()
 {
-  QMessageBox ask(this);
+  QMessageBox ask(gui()->central_wdg);
   int ret;
 
   ask.setText(_("Are you sure you want to disband that unit?"));
@@ -1402,7 +1402,7 @@
 void city_dialog::cma_remove()
 {
   int i;
-  QMessageBox ask;
+  QMessageBox ask(gui()->central_wdg);
   int ret;
 
   i = cma_table->currentRow();
@@ -1895,7 +1895,7 @@
 ****************************************************************************/
 void city_dialog::dbl_click(QTableWidgetItem *item)
 {
-  QMessageBox ask(this);
+  QMessageBox ask(gui()->central_wdg);
   QString s;
   QVariant qvar;
   char buf[256];
@@ -2156,7 +2156,7 @@
   const char *name = city_production_name_translation(pcity);
   int value = city_production_buy_gold_cost(pcity);
   const QString title = _("Buy ?");
-  QMessageBox ask(this);
+  QMessageBox ask(gui()->central_wdg);
 
   if (!can_client_issue_orders()) {
     return;

Modified: branches/S2_6/client/gui-qt/citydlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.h?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/citydlg.h       (original)
+++ branches/S2_6/client/gui-qt/citydlg.h       Mon Nov 16 19:52:59 2015
@@ -90,6 +90,7 @@
   QAction *unload;
   QAction *upgrade;
   QAction *unload_trans;
+  QMenu *unit_menu;
 
 public:
   unit_item(QWidget *parent ,struct unit *punit, bool supp = false, int 
happy_cost = 0);


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

Reply via email to