summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-04-04 07:19:37 +1100
committer Vas Crabb <vas@vastheman.com>2026-04-04 07:19:37 +1100
commit5efd5fc946137dd434c04b6c49d2678f3e9e41d3 (patch)
treea92720a92f17e5e49ec62fb55f542db2620c410b
parent21defbea953c36bba6eeec5ea6f7cf6d3cd310d8 (diff)
ui/submenu.cpp: Fixed potential crash in Video Options menu on Windows.
-rw-r--r--scripts/src/mame/frontend.lua6
-rw-r--r--src/frontend/mame/ui/submenu.cpp48
2 files changed, 27 insertions, 27 deletions
diff --git a/scripts/src/mame/frontend.lua b/scripts/src/mame/frontend.lua
index 73e6c438cfb..51d61d9da9c 100644
--- a/scripts/src/mame/frontend.lua
+++ b/scripts/src/mame/frontend.lua
@@ -51,12 +51,6 @@ if (_OPTIONS["targetos"] == "windows") then
}
end
-if (_OPTIONS["osd"] == "sdl") then
- defines {
- "UI_SDL",
- }
-end
-
files {
MAME_DIR .. "src/frontend/mame/audit.cpp",
MAME_DIR .. "src/frontend/mame/audit.h",
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index f5d0611f03e..f14a6e055d5 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -15,7 +15,7 @@
#include "ui/ui.h"
#include "ui/utils.h"
-#if defined(UI_WINDOWS) && !defined(UI_SDL)
+#if defined(UI_WINDOWS)
#include "../osd/windows/winmain.h"
#else
#include "../osd/modules/lib/osdobj_common.h"
@@ -123,7 +123,7 @@ std::vector<submenu::option> submenu::video_options()
{ option_type::HEAD, N_("Video Options") },
{ option_type::OSD, N_("Video Mode"), OSDOPTION_VIDEO },
{ option_type::OSD, N_("Number Of Screens"), OSDOPTION_NUMSCREENS },
-#if defined(UI_WINDOWS) && !defined(UI_SDL)
+#if defined(UI_WINDOWS)
{ option_type::OSD, N_("Triple Buffering"), WINOPTION_TRIPLEBUFFER },
{ option_type::OSD, N_("HLSL"), WINOPTION_HLSL_ENABLE },
#endif
@@ -168,17 +168,17 @@ submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<
else
opts = dynamic_cast<core_options *>(options);
- for (option &sm_option : m_options)
+ for (auto sm_option = m_options.begin(); sm_option != m_options.end(); )
{
- switch (sm_option.type)
+ switch (sm_option->type)
{
case option_type::EMU:
- sm_option.entry = opts->get_entry(sm_option.name);
- sm_option.options = opts;
- if ((sm_option.entry->type() == core_options::option_type::STRING) || (sm_option.entry->type() == core_options::option_type::PATH) || (sm_option.entry->type() == core_options::option_type::MULTIPATH))
+ sm_option->entry = opts->get_entry(sm_option->name);
+ sm_option->options = opts;
+ if ((sm_option->entry->type() == core_options::option_type::STRING) || (sm_option->entry->type() == core_options::option_type::PATH) || (sm_option->entry->type() == core_options::option_type::MULTIPATH))
{
- sm_option.value.clear();
- std::string namestr(sm_option.entry->description());
+ sm_option->value.clear();
+ std::string namestr(sm_option->entry->description());
int lparen = namestr.find_first_of('(', 0);
int vslash = namestr.find_first_of('|', lparen + 1);
int rparen = namestr.find_first_of(')', vslash + 1);
@@ -189,23 +189,28 @@ submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<
namestr.erase(0, lparen + 1);
while ((semi = namestr.find_first_of('|')) != -1)
{
- sm_option.value.emplace_back(namestr.substr(0, semi));
+ sm_option->value.emplace_back(namestr.substr(0, semi));
namestr.erase(0, semi + 1);
}
- sm_option.value.emplace_back(namestr);
+ sm_option->value.emplace_back(namestr);
}
}
break;
case option_type::OSD:
- sm_option.entry = opts->get_entry(sm_option.name);
- sm_option.options = opts;
- if ((sm_option.entry->type() == core_options::option_type::STRING) || (sm_option.entry->type() == core_options::option_type::PATH) || (sm_option.entry->type() == core_options::option_type::MULTIPATH))
+ sm_option->entry = opts->get_entry(sm_option->name);
+ if (!sm_option->entry)
+ {
+ sm_option = m_options.erase(sm_option);
+ continue;
+ }
+ sm_option->options = opts;
+ if ((sm_option->entry->type() == core_options::option_type::STRING) || (sm_option->entry->type() == core_options::option_type::PATH) || (sm_option->entry->type() == core_options::option_type::MULTIPATH))
{
- sm_option.value.clear();
- std::string descr(machine().options().get_entry(sm_option.name)->description()), delim(", ");
+ sm_option->value.clear();
+ std::string descr(machine().options().get_entry(sm_option->name)->description()), delim(", ");
descr.erase(0, descr.find(":") + 2);
- std::string default_value(sm_option.entry->default_value());
+ std::string default_value(sm_option->entry->default_value());
std::string auto_value(OSDOPTVAL_AUTO);
if (default_value == auto_value)
descr = auto_value + delim + descr;
@@ -218,23 +223,24 @@ submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<
{
std::string txt(descr.substr(p1, p2 - p1));
if (txt != "or")
- sm_option.value.push_back(txt);
+ sm_option->value.push_back(txt);
}
else
{
- sm_option.value.push_back(descr.substr(p1));
+ sm_option->value.push_back(descr.substr(p1));
break;
}
}
}
break;
case option_type::UI:
- sm_option.entry = mui.options().get_entry(sm_option.name);
- sm_option.options = dynamic_cast<core_options*>(&mui.options());
+ sm_option->entry = mui.options().get_entry(sm_option->name);
+ sm_option->options = dynamic_cast<core_options *>(&mui.options());
break;
default:
break;
}
+ ++sm_option;
}
}