mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
ui/inputmap: prevent race condition between ui_input().pressed() and poll()
This commit is contained in:
parent
7812e9ebb6
commit
0cd6c079c9
@ -245,6 +245,7 @@ menu_input::menu_input(mame_ui_manager &mui, render_container &container)
|
|||||||
, erroritem(nullptr)
|
, erroritem(nullptr)
|
||||||
, lastitem(nullptr)
|
, lastitem(nullptr)
|
||||||
, record_next(false)
|
, record_next(false)
|
||||||
|
, modified_ticks(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,11 +323,15 @@ void menu_input::handle()
|
|||||||
// if we are polling, handle as a special case
|
// if we are polling, handle as a special case
|
||||||
input_item_data *const item = pollingitem;
|
input_item_data *const item = pollingitem;
|
||||||
|
|
||||||
|
// prevent race condition between ui_input().pressed() and poll()
|
||||||
|
if (modified_ticks == 0 && seq_poll->modified())
|
||||||
|
modified_ticks = osd_ticks();
|
||||||
|
|
||||||
if (machine().ui_input().pressed(IPT_UI_CANCEL))
|
if (machine().ui_input().pressed(IPT_UI_CANCEL))
|
||||||
{
|
{
|
||||||
// if UI_CANCEL is pressed, abort
|
// if UI_CANCEL is pressed, abort
|
||||||
pollingitem = nullptr;
|
pollingitem = nullptr;
|
||||||
if (!seq_poll->modified())
|
if (!seq_poll->modified() || modified_ticks == osd_ticks())
|
||||||
{
|
{
|
||||||
// cancelled immediately - toggle between default and none
|
// cancelled immediately - toggle between default and none
|
||||||
record_next = false;
|
record_next = false;
|
||||||
@ -368,6 +373,7 @@ void menu_input::handle()
|
|||||||
case IPT_UI_SELECT: // an item was selected: begin polling
|
case IPT_UI_SELECT: // an item was selected: begin polling
|
||||||
errormsg.clear();
|
errormsg.clear();
|
||||||
erroritem = nullptr;
|
erroritem = nullptr;
|
||||||
|
modified_ticks = 0;
|
||||||
pollingitem = &item;
|
pollingitem = &item;
|
||||||
lastitem = &item;
|
lastitem = &item;
|
||||||
starting_seq = item.seq;
|
starting_seq = item.seq;
|
||||||
|
@ -75,6 +75,7 @@ private:
|
|||||||
input_item_data *erroritem;
|
input_item_data *erroritem;
|
||||||
input_item_data *lastitem;
|
input_item_data *lastitem;
|
||||||
bool record_next;
|
bool record_next;
|
||||||
|
osd_ticks_t modified_ticks;
|
||||||
input_seq starting_seq;
|
input_seq starting_seq;
|
||||||
|
|
||||||
virtual void custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) override;
|
virtual void custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user