settings/input: Fix updateControls crashes

updateControls assumes that when activeMapping is set, an item from
mappingList is guaranteed to be selected. However, there are several
scenarios that break this assumption:

- changing port during an active mapping
- changing device during an active mapping
- reloading the input driver during an active mapping

In all of these cases, updateControls is eventually called. It sees an
outstanding activeMapping and proceeds to figure out the offset of the
currently selected item, but since there are no selected items it ends
up dereferncing a null pointer.

The assumption can be honored by having reloadMappings cancel the
outstanding activeMapping, thus preventing a crash.

Fixes #4.
This commit is contained in:
Sintendo 2020-04-01 00:06:00 +02:00
parent 69d527f322
commit 97452b6ec3
1 changed files with 1 additions and 1 deletions

View File

@ -124,7 +124,7 @@ auto InputSettings::reloadMappings() -> void {
for(uint n : range(BindingLimit)) item.append(TableViewCell());
}
refreshMappings();
updateControls();
cancelMapping();
}
auto InputSettings::refreshMappings() -> void {