BitUtils: Make Count{Leading,Trailing}Zeros UB for value==0

This commit is contained in:
Connor McLaughlin
2020-04-26 18:32:23 +10:00
parent 38b075c014
commit 5671fde1ae
3 changed files with 19 additions and 21 deletions

View File

@ -168,7 +168,8 @@ bool InputButtonBindingWidget::eventFilter(QObject* watched, QEvent* event)
}
else if (event_type == QEvent::MouseButtonRelease)
{
const u32 button_index = CountTrailingZeros(static_cast<u32>(static_cast<const QMouseEvent*>(event)->button()));
const u32 button_mask = static_cast<u32>(static_cast<const QMouseEvent*>(event)->button());
const u32 button_index = (button_mask == 0u) ? 0 : CountTrailingZeros(button_mask);
m_new_binding_value = QStringLiteral("Mouse/Button%1").arg(button_index + 1);
setNewBinding();
stopListeningForInput();