diff options
author | 2017-10-18 20:47:05 -0400 | |
---|---|---|
committer | 2017-10-18 20:47:26 -0400 | |
commit | aef651f228b10333242d8d4dbcc17af836ded5df (patch) | |
tree | 09e3e7a6e66b47e3194bb43712867cf4fc5427c6 /src/frontend/mame/ui/inputmap.cpp | |
parent | cffa7ecc342dba1a6bce9d5d0045e01ff759108b (diff) |
inputmap.cpp: Avert potential crash when populating DSW menu (nw)
Diffstat (limited to 'src/frontend/mame/ui/inputmap.cpp')
-rw-r--r-- | src/frontend/mame/ui/inputmap.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 5a56aee53c4..ed51a903b9d 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -554,27 +554,30 @@ void menu_settings::populate(float &customtop, float &custombottom) for (ioport_field &field : port.second->fields()) if (field.type() == type && field.enabled()) { - uint32_t flags = 0; + if (!field.settings().empty()) + { + uint32_t flags = 0; - /* set the left/right flags appropriately */ - if (field.has_previous_setting()) - flags |= FLAG_LEFT_ARROW; - if (field.has_next_setting()) - flags |= FLAG_RIGHT_ARROW; + /* set the left/right flags appropriately */ + if (field.has_previous_setting()) + flags |= FLAG_LEFT_ARROW; + if (field.has_next_setting()) + flags |= FLAG_RIGHT_ARROW; - /* add the menu item */ - if (strcmp(field.device().tag(), prev_owner.c_str()) != 0) - { - if (first_entry) - first_entry = false; - else - item_append(menu_item_type::SEPARATOR); - string_format("[root%s]", field.device().tag()); - item_append(string_format("[root%s]", field.device().tag()), "", 0, nullptr); - prev_owner.assign(field.device().tag()); - } + /* add the menu item */ + if (strcmp(field.device().tag(), prev_owner.c_str()) != 0) + { + if (first_entry) + first_entry = false; + else + item_append(menu_item_type::SEPARATOR); + string_format("[root%s]", field.device().tag()); + item_append(string_format("[root%s]", field.device().tag()), "", 0, nullptr); + prev_owner.assign(field.device().tag()); + } - item_append(field.name(), field.setting_name(), flags, (void *)&field); + item_append(field.name(), field.setting_name(), flags, (void *)&field); + } /* for DIP switches, build up the model */ if (type == IPT_DIPSWITCH && !field.diplocations().empty()) |