mirror of https://github.com/PCSX2/pcsx2.git
GSdx: Improve robustness of ComboBoxInit()
Previously, the combobox will reach an indeterminate state whenever it's passed with a value out of range via ComboBoxInit(). To avoid such cases, let's initialize the current selection of the combobox with the front element of the settings vector whenever we detect an out of range value which is not declared in the vector. To reproduce the issue, set "Renderer" to some sort of crazy value like 50 in the GSdx.ini file and it'll mess up the whole GSdx plugin dialog really bad. This patch prevents such undesirable behavior by simply selecting the front element in the vector when we read an unsupported value.
This commit is contained in:
parent
c56ac2cf3e
commit
eda22c241d
|
@ -166,10 +166,17 @@ void GSDialog::SetTextAsInt(UINT id, int i)
|
||||||
|
|
||||||
void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, int32_t selectionValue, int32_t maxValue)
|
void GSDialog::ComboBoxInit(UINT id, const vector<GSSetting>& settings, int32_t selectionValue, int32_t maxValue)
|
||||||
{
|
{
|
||||||
|
if (settings.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
HWND hWnd = GetDlgItem(m_hWnd, id);
|
HWND hWnd = GetDlgItem(m_hWnd, id);
|
||||||
|
|
||||||
SendMessage(hWnd, CB_RESETCONTENT, 0, 0);
|
SendMessage(hWnd, CB_RESETCONTENT, 0, 0);
|
||||||
|
|
||||||
|
const auto is_present = [=](const GSSetting& x) { return selectionValue == x.value; };
|
||||||
|
if (std::none_of(settings.begin(), settings.end(), is_present))
|
||||||
|
selectionValue = settings.front().value;
|
||||||
|
|
||||||
for(size_t i = 0; i < settings.size(); i++)
|
for(size_t i = 0; i < settings.size(); i++)
|
||||||
{
|
{
|
||||||
const GSSetting& s = settings[i];
|
const GSSetting& s = settings[i];
|
||||||
|
|
Loading…
Reference in New Issue