From e02815dc30f931136c736200f40499e10a5d90e2 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 31 Jul 2015 16:46:00 -0400 Subject: [PATCH] Fix manipulator crash when selecting from empty custom profession list --- NEWS | 1 + plugins/manipulator.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 25a9870a5..19c3f9f09 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,7 @@ DFHack Future buildingplan: Now supports hatch covers gui/hack-wish now properly assigns quality to items. gui/gm-editor handles lua tables properly + manipulator: fixed crash when selecting custom professions when none are found search: fixed crash in unit list after cancelling a job stockpiles: now checks/sanitizes filenames when saving stocks: fixed a crash when right-clicking diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 6a69d7996..d6d2cb222 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -998,6 +998,8 @@ public: } void select_profession(size_t selected) { + if (selected >= manager.templates.size()) + return; ProfessionTemplate prof = manager.templates[selected - 1]; for (auto it = units.begin(); it != units.end(); ++it) @@ -1013,6 +1015,11 @@ public: Screen::clear(); int x = 2, y = 2; Screen::drawBorder(" Dwarf Manipulator - Custom Profession "); + if (!manager.templates.size()) + { + OutputString(COLOR_LIGHTRED, x, y, "No saved professions"); + return; + } if (selection_empty) { OutputString(COLOR_LIGHTRED, x, y, "No dwarves selected!");