From 13647329f9bb400b4f46fb0334ed745b95c0944e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 31 Dec 2018 09:41:43 +0100 Subject: [PATCH] Ref T494, fixed voiceroom member updates * changedUrl was actually equal URL, no idea how this ever did work out * unnecessary redundant updates of voice room members fixed --- .../components/voiceroomscomponent.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/blackgui/components/voiceroomscomponent.cpp b/src/blackgui/components/voiceroomscomponent.cpp index b0e2fbdad..a4cfa3bfa 100644 --- a/src/blackgui/components/voiceroomscomponent.cpp +++ b/src/blackgui/components/voiceroomscomponent.cpp @@ -80,19 +80,20 @@ namespace BlackGui void CVoiceRoomsComponent::updateAudioVoiceRoomsFromContext(const CVoiceRoomList &selectedVoiceRooms, bool connected) { - Q_ASSERT(selectedVoiceRooms.size() == 2); - CVoiceRoom room1 = selectedVoiceRooms[0]; - CVoiceRoom room2 = selectedVoiceRooms[1]; + if (!sGui || sGui->isShuttingDown()) { return; } - // remark + Q_ASSERT(selectedVoiceRooms.size() == 2); + const CVoiceRoom room1 = selectedVoiceRooms[0]; + const CVoiceRoom room2 = selectedVoiceRooms[1]; + + // remark: // isAudioPlaying() is not set, as this is only a temporary value when really "something is playing" - bool changedUrl1 = (room1.getVoiceRoomUrl() == ui->le_CockpitVoiceRoomCom1->text()); + const bool changedUrl1 = (room1.getVoiceRoomUrl() != ui->le_CockpitVoiceRoomCom1->text()); ui->le_CockpitVoiceRoomCom1->setText(room1.getVoiceRoomUrl()); if (room1.isConnected()) { ui->le_CockpitVoiceRoomCom1->setStyleSheet("background: green"); - if (sGui->getIContextAudio()) ui->tvp_CockpitVoiceRoom1->updateContainer(sGui->getIContextAudio()->getRoomUsers(BlackMisc::Aviation::CComSystem::Com1)); } else { @@ -100,7 +101,7 @@ namespace BlackGui ui->tvp_CockpitVoiceRoom1->clear(); } - bool changedUrl2 = (room2.getVoiceRoomUrl() == ui->le_CockpitVoiceRoomCom2->text()); + const bool changedUrl2 = (room2.getVoiceRoomUrl() != ui->le_CockpitVoiceRoomCom2->text()); ui->le_CockpitVoiceRoomCom2->setText(room2.getVoiceRoomUrl()); if (room2.isConnected()) { @@ -111,16 +112,16 @@ namespace BlackGui ui->le_CockpitVoiceRoomCom2->setStyleSheet(""); ui->tvp_CockpitVoiceRoom2->clear(); } + + // for unconnected we already + if (connected) { this->updateVoiceRoomMembers(); } + if (changedUrl1 || changedUrl2) { - this->updateVoiceRoomMembers(); - // notify if (sGui->getIContextAudio()) { - CNotificationSounds::NotificationFlag sound = connected ? - CNotificationSounds::NotificationVoiceRoomJoined : - CNotificationSounds::NotificationVoiceRoomLeft; + const CNotificationSounds::NotificationFlag sound = connected ? CNotificationSounds::NotificationVoiceRoomJoined : CNotificationSounds::NotificationVoiceRoomLeft; sGui->getIContextAudio()->playNotification(sound, true); } } @@ -128,10 +129,10 @@ namespace BlackGui void CVoiceRoomsComponent::updateVoiceRoomMembers() { - if (!sGui->getIContextAudio()) { return; } + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; } if (!ui->le_CockpitVoiceRoomCom1->text().trimmed().isEmpty()) { - ui->tvp_CockpitVoiceRoom1->updateContainer(sGui->getIContextAudio()->getRoomUsers(BlackMisc::Aviation::CComSystem::Com1)); + ui->tvp_CockpitVoiceRoom1->updateContainer(sGui->getIContextAudio()->getRoomUsers(CComSystem::Com1)); } else { @@ -140,7 +141,7 @@ namespace BlackGui if (!ui->le_CockpitVoiceRoomCom2->text().trimmed().isEmpty()) { - ui->tvp_CockpitVoiceRoom2->updateContainer(sGui->getIContextAudio()->getRoomUsers(BlackMisc::Aviation::CComSystem::Com2)); + ui->tvp_CockpitVoiceRoom2->updateContainer(sGui->getIContextAudio()->getRoomUsers(CComSystem::Com2)); } else {