fixed crash when displaying external DATs file in some circumstances. (nw)

This commit is contained in:
dankan1890 2016-03-06 21:37:53 +01:00
parent f0f4c30597
commit d13aba424f
5 changed files with 67 additions and 34 deletions

View File

@ -31,7 +31,6 @@ public:
void load_software_info(std::string &softlist, std::string &buffer, std::string &softname, std::string &parentname); void load_software_info(std::string &softlist, std::string &buffer, std::string &softname, std::string &parentname);
void command_sub_menu(const game_driver *drv, std::vector<std::string> &menuitems); void command_sub_menu(const game_driver *drv, std::vector<std::string> &menuitems);
void reset_run() { first_run = true; } void reset_run() { first_run = true; }
bool has_software(std::string &softlist, std::string &softname, std::string &parentname);
std::string rev_history() const { return m_history_rev; } std::string rev_history() const { return m_history_rev; }
std::string rev_mameinfo() const { return m_mame_rev; } std::string rev_mameinfo() const { return m_mame_rev; }
@ -45,9 +44,11 @@ public:
bool has_command(const game_driver *driver) { return (m_cmdidx.find(driver) != m_cmdidx.end()); } bool has_command(const game_driver *driver) { return (m_cmdidx.find(driver) != m_cmdidx.end()); }
bool has_sysinfo(const game_driver *driver) { return (m_sysidx.find(driver) != m_sysidx.end()); } bool has_sysinfo(const game_driver *driver) { return (m_sysidx.find(driver) != m_sysidx.end()); }
bool has_story(const game_driver *driver) { return (m_storyidx.find(driver) != m_storyidx.end()); } bool has_story(const game_driver *driver) { return (m_storyidx.find(driver) != m_storyidx.end()); }
bool has_software(std::string &softlist, std::string &softname, std::string &parentname);
bool has_data(const game_driver *d) bool has_data(const game_driver *a = nullptr)
{ {
const game_driver *d = (a != nullptr) ? a : &machine().system();
return (has_history(d) || has_mameinfo(d) || has_messinfo(d) || has_command(d) || has_sysinfo(d) || has_story(d)); return (has_history(d) || has_mameinfo(d) || has_messinfo(d) || has_command(d) || has_sysinfo(d) || has_story(d));
} }
private: private:

View File

@ -99,10 +99,7 @@ void ui_menu_dats_view::handle()
void ui_menu_dats_view::populate() void ui_menu_dats_view::populate()
{ {
machine().pause(); machine().pause();
if (!issoft) (issoft == true) ? get_data_sw() : get_data();
get_data();
else
get_data_sw();
item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr); item_append(MENU_SEPARATOR_ITEM, nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), nullptr);
customtop = 2.0f * machine().ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER; customtop = 2.0f * machine().ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
@ -119,12 +116,7 @@ void ui_menu_dats_view::custom_render(void *selectedref, float top, float bottom
ui_manager &mui = machine().ui(); ui_manager &mui = machine().ui();
float maxwidth = origx2 - origx1; float maxwidth = origx2 - origx1;
float width; float width;
std::string driver; std::string driver = (issoft == true) ? m_swinfo->longname : m_driver->description;
if (issoft)
driver = m_swinfo->longname;
else
driver = m_driver->description;
mui.draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, mui.draw_text_full(container, driver.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr); DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
@ -251,7 +243,6 @@ void ui_menu_dats_view::get_data()
{ {
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1)); item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1));
} }
} }
@ -276,7 +267,6 @@ void ui_menu_dats_view::get_data_sw()
{ {
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x])); std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1)); item_append(tempbuf.c_str(), nullptr, (MENU_FLAG_UI_DATS | MENU_FLAG_DISABLE), (void *)(FPTR)(x + 1));
} }
} }

View File

@ -132,7 +132,7 @@ void ui_menu_main::populate()
item_append(_("Cheat"), nullptr, 0, (void *)CHEAT); item_append(_("Cheat"), nullptr, 0, (void *)CHEAT);
// add dats menu // add dats menu
if (machine().ui().options().enabled_dats() && machine().datfile().has_data(&machine().system())) if (machine().ui().options().enabled_dats() && machine().datfile().has_data())
item_append(_("External DAT View"), nullptr, 0, (void *)EXTERNAL_DATS); item_append(_("External DAT View"), nullptr, 0, (void *)EXTERNAL_DATS);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);

View File

@ -299,10 +299,31 @@ void ui_menu_select_game::handle()
} }
// Infos // Infos
else if (ui_globals::rpanel == RP_INFOS && ui_globals::curdats_view > UI_FIRST_LOAD) else if (ui_globals::rpanel == RP_INFOS)
{ {
ui_globals::curdats_view--; if (!isfavorite())
topline_datsview = 0; {
const game_driver *drv = (const game_driver *)m_event->itemref;
if ((FPTR)drv > skip_main_items && ui_globals::curdats_view > UI_FIRST_LOAD)
{
ui_globals::curdats_view--;
topline_datsview = 0;
}
}
else
{
ui_software_info *drv = (ui_software_info *)m_event->itemref;
if (drv->startempty == 1 && ui_globals::curdats_view > UI_FIRST_LOAD)
{
ui_globals::curdats_view--;
topline_datsview = 0;
}
else if ((FPTR)drv > skip_main_items && ui_globals::cur_sw_dats_view > 0)
{
ui_globals::cur_sw_dats_view--;
topline_datsview = 0;
}
}
} }
} }
@ -318,10 +339,31 @@ void ui_menu_select_game::handle()
} }
// Infos // Infos
else if (ui_globals::rpanel == RP_INFOS && ui_globals::curdats_view < UI_LAST_LOAD) else if (ui_globals::rpanel == RP_INFOS)
{ {
ui_globals::curdats_view++; if (!isfavorite())
topline_datsview = 0; {
const game_driver *drv = (const game_driver *)m_event->itemref;
if ((FPTR)drv > skip_main_items && ui_globals::curdats_view < UI_LAST_LOAD)
{
ui_globals::curdats_view++;
topline_datsview = 0;
}
}
else
{
ui_software_info *drv = (ui_software_info *)m_event->itemref;
if (drv->startempty == 1 && ui_globals::curdats_view < UI_LAST_LOAD)
{
ui_globals::curdats_view++;
topline_datsview = 0;
}
else if ((FPTR)drv > skip_main_items && ui_globals::cur_sw_dats_view < 1)
{
ui_globals::cur_sw_dats_view++;
topline_datsview = 0;
}
}
} }
} }
@ -363,13 +405,15 @@ void ui_menu_select_game::handle()
} }
else else
{ {
ui_software_info *swinfo = (ui_software_info *)m_event->itemref; ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
if ((FPTR)swinfo > skip_main_items && machine().datfile().has_data(swinfo->driver)) datfile_manager &mdat = machine().datfile();
if ((FPTR)ui_swinfo > skip_main_items)
{ {
if (swinfo->startempty == 1) if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver))
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, swinfo->driver)); ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo->driver));
else else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty())
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, swinfo)); ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo));
} }
} }
} }

View File

@ -242,14 +242,12 @@ void ui_menu_select_software::handle()
else if (m_event->iptkey == IPT_UI_DATS && machine().ui().options().enabled_dats()) else if (m_event->iptkey == IPT_UI_DATS && machine().ui().options().enabled_dats())
{ {
ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref; ui_software_info *ui_swinfo = (ui_software_info *)m_event->itemref;
datfile_manager &mdat = machine().datfile();
if ((FPTR)ui_swinfo > 1 && machine().datfile().has_data(ui_swinfo->driver)) if (ui_swinfo->startempty == 1 && mdat.has_history(ui_swinfo->driver))
{ ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo->driver));
if (ui_swinfo->startempty == 1) else if (mdat.has_software(ui_swinfo->listname, ui_swinfo->shortname, ui_swinfo->parentname) || !ui_swinfo->usage.empty())
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo->driver)); ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo));
else
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, ui_swinfo));
}
} }
// handle UI_LEFT_PANEL // handle UI_LEFT_PANEL