Author: cazfi
Date: Tue Jan  5 16:42:02 2016
New Revision: 31365

URL: http://svn.gna.org/viewcvs/freeciv?rev=31365&view=rev
Log:
Fixed ruledit crash when trying to delete an item without one selected.

See bug #24272

Modified:
    branches/S2_6/tools/ruledit/tab_building.cpp
    branches/S2_6/tools/ruledit/tab_tech.cpp
    branches/S2_6/tools/ruledit/tab_unit.cpp

Modified: branches/S2_6/tools/ruledit/tab_building.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/tab_building.cpp?rev=31365&r1=31364&r2=31365&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/tab_building.cpp        (original)
+++ branches/S2_6/tools/ruledit/tab_building.cpp        Tue Jan  5 16:42:02 2016
@@ -162,15 +162,17 @@
 **************************************************************************/
 void tab_building::delete_now()
 {
-  ui->clear_required(improvement_rule_name(selected));
-  if (is_building_needed(selected, &ruledit_qt_display_requirers)) {
-    return;
-  }
-
-  selected->disabled = true;
-
-  refresh();
-  update_bldg_info(0);
+  if (selected != 0) {
+    ui->clear_required(improvement_rule_name(selected));
+    if (is_building_needed(selected, &ruledit_qt_display_requirers)) {
+      return;
+    }
+
+    selected->disabled = true;
+
+    refresh();
+    update_bldg_info(0);
+  }
 }
 
 /**************************************************************************

Modified: branches/S2_6/tools/ruledit/tab_tech.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/tab_tech.cpp?rev=31365&r1=31364&r2=31365&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/tab_tech.cpp    (original)
+++ branches/S2_6/tools/ruledit/tab_tech.cpp    Tue Jan  5 16:42:02 2016
@@ -326,15 +326,17 @@
 **************************************************************************/
 void tab_tech::delete_now()
 {
-  ui->clear_required(advance_rule_name(selected));
-  if (is_tech_needed(selected, &ruledit_qt_display_requirers)) {
-    return;
-  }
-
-  selected->require[AR_ONE] = A_NEVER;
-
-  refresh();
-  update_tech_info(0);
+  if (selected != 0) {
+    ui->clear_required(advance_rule_name(selected));
+    if (is_tech_needed(selected, &ruledit_qt_display_requirers)) {
+      return;
+    }
+
+    selected->require[AR_ONE] = A_NEVER;
+
+    refresh();
+    update_tech_info(0);
+  }
 }
 
 /**************************************************************************

Modified: branches/S2_6/tools/ruledit/tab_unit.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/tab_unit.cpp?rev=31365&r1=31364&r2=31365&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/tab_unit.cpp    (original)
+++ branches/S2_6/tools/ruledit/tab_unit.cpp    Tue Jan  5 16:42:02 2016
@@ -163,15 +163,17 @@
 **************************************************************************/
 void tab_unit::delete_now()
 {
-  ui->clear_required(utype_rule_name(selected));
-  if (is_utype_needed(selected, &ruledit_qt_display_requirers)) {
-    return;
-  }
-
-  selected->disabled = true;
-
-  refresh();
-  update_utype_info(0);
+  if (selected != 0) {
+    ui->clear_required(utype_rule_name(selected));
+    if (is_utype_needed(selected, &ruledit_qt_display_requirers)) {
+      return;
+    }
+
+    selected->disabled = true;
+
+    refresh();
+    update_utype_info(0);
+  }
 }
 
 /**************************************************************************


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

Reply via email to