Fix for bug - switch association fails (#5947)

* Fix for bug - switch association fails

Signed-off-by: T.J. McGrath-Daly <tj.mcgrath.daly@huawei.com>

* Change message box button from 'Yes' to 'Ok'

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Changed message box button from 'Yes' to 'Ok'

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

Co-authored-by: Tobias Alexander Franke <tobias.alexander.franke@huawei.com>
Co-authored-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>
This commit is contained in:
tjmgd
2021-12-02 23:50:51 +00:00
committed by GitHub
parent f56bbb96b0
commit 631ebacc0c
4 changed files with 65 additions and 0 deletions
@@ -808,6 +808,21 @@ namespace AudioControls
{
AZ::StringFunc::Path::StripExtension(sControlName);
}
else if (eControlType == eACET_SWITCH_STATE)
{
if (!pATLParent->SwitchStateConnectionCheck(pAudioSystemControl))
{
QMessageBox messageBox(this);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setWindowTitle("Audio Controls Editor");
messageBox.setText("Not in the same switch group, connection failed.");
if (messageBox.exec() == QMessageBox::Ok)
{
return;
}
}
}
CATLControl* pTargetControl2 = m_pTreeModel->CreateControl(eControlType, sControlName, pATLParent);
if (pTargetControl2)
{
@@ -368,4 +368,36 @@ namespace AudioControls
}
}
bool CATLControl::SwitchStateConnectionCheck(IAudioSystemControl* middlewareControl)
{
if (IAudioSystemEditor* audioSystemImpl = CAudioControlsEditorPlugin::GetImplementationManager()->GetImplementation())
{
CID parentID = middlewareControl->GetParent()->GetId();
EACEControlType compatibleType = audioSystemImpl->ImplTypeToATLType(middlewareControl->GetType());
if (compatibleType == EACEControlType::eACET_SWITCH_STATE && m_type == EACEControlType::eACET_SWITCH)
{
for (auto& child : m_children)
{
for (int j = 0; child && j < child->ConnectionCount(); ++j)
{
TConnectionPtr tmpConnection = child->GetConnectionAt(j);
if (tmpConnection)
{
IAudioSystemControl* tmpMiddlewareControl = audioSystemImpl->GetControl(tmpConnection->GetID());
EACEControlType controlType = audioSystemImpl->ImplTypeToATLType(tmpMiddlewareControl->GetType());
if (tmpMiddlewareControl && controlType == EACEControlType::eACET_SWITCH_STATE)
{
if (parentID != ACE_INVALID_CID && tmpMiddlewareControl->GetParent()->GetId() != parentID)
{
return false;
}
}
}
}
}
}
}
return true;
}
} // namespace AudioControls
@@ -144,6 +144,8 @@ namespace AudioControls
void SignalConnectionAdded(IAudioSystemControl* middlewareControl);
void SignalConnectionRemoved(IAudioSystemControl* middlewareControl);
bool SwitchStateConnectionCheck(IAudioSystemControl* middlewareControl);
private:
void SetId(CID id);
void SetType(EACEControlType type);
@@ -128,6 +128,22 @@ namespace AudioControls
}
else
{
if (m_control->GetType() == EACEControlType::eACET_SWITCH_STATE)
{
if (!m_control->GetParent()->SwitchStateConnectionCheck(middlewareControl))
{
QMessageBox messageBox(this);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setWindowTitle("Audio Controls Editor");
messageBox.setText("Not in the same switch group, connection failed.");
if (messageBox.exec() == QMessageBox::Ok)
{
return;
}
}
}
connection = audioSystemImpl->CreateConnectionToControl(m_control->GetType(), middlewareControl);
if (connection)
{