@@ -277,7 +277,13 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
277277 {
278278 // initiate connection (always show the address in the mixer board
279279 // (no alias))
280- Connect ( strConnOnStartupAddress, strConnOnStartupAddress );
280+
281+ // initiate connection
282+ // TODO: Refactor this for failing call on Connect()
283+
284+ pClient->Connect ( strConnOnStartupAddress, strConnOnStartupAddress );
285+ // TODO: Find out why without this the mixer status issue still occurs.
286+ OnConnect ( strConnOnStartupAddress );
281287 }
282288
283289 // File menu --------------------------------------------------------------
@@ -473,7 +479,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
473479 // other
474480 QObject::connect ( pClient, &CClient::ConClientListMesReceived, this , &CClientDlg::OnConClientListMesReceived );
475481
476- QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnected );
482+ QObject::connect ( pClient, &CClient::Connecting, this , &CClientDlg::OnConnect );
483+
484+ QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnect );
477485
478486 QObject::connect ( pClient, &CClient::ChatTextReceived, this , &CClientDlg::OnChatTextReceived );
479487
@@ -608,11 +616,8 @@ void CClientDlg::closeEvent ( QCloseEvent* Event )
608616 ConnectDlg.close ();
609617 AnalyzerConsole.close ();
610618
611- // if connected, terminate connection
612- if ( pClient->IsRunning () )
613- {
614- pClient->Stop ();
615- }
619+ // Disconnect if needed
620+ pClient->Disconnect ();
616621
617622 // make sure all current fader settings are applied to the settings struct
618623 MainMixerBoard->StoreAllFaderSettings ();
@@ -730,16 +735,14 @@ void CClientDlg::OnConnectDlgAccepted()
730735 }
731736 }
732737
733- // first check if we are already connected, if this is the case we have to
734- // disconnect the old server first
735- if ( pClient->IsRunning () )
738+ // initiate connection
739+ // TODO: Refactor this for failing call on Connect()
740+
741+ if ( pClient->Connect ( strSelectedAddress, strMixerBoardLabel ) )
736742 {
737- Disconnect ( );
743+ OnConnect ( strMixerBoardLabel );
738744 }
739745
740- // initiate connection
741- Connect ( strSelectedAddress, strMixerBoardLabel );
742-
743746 // reset flag
744747 bConnectDlgWasShown = false ;
745748 }
@@ -748,13 +751,10 @@ void CClientDlg::OnConnectDlgAccepted()
748751void CClientDlg::OnConnectDisconBut ()
749752{
750753 // the connect/disconnect button implements a toggle functionality
751- if ( pClient->IsRunning () )
752- {
753- Disconnect ();
754- SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
755- }
756- else
754+ if ( !pClient->Disconnect () )
757755 {
756+ // If the client didn't disconnect, we assume that we weren't connected. Thus show the connect dialog
757+ // TODO: Refactor to have robust error handling
758758 ShowConnectionSetupDialog ();
759759 }
760760}
@@ -859,7 +859,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType )
859859 // disconnect from that server.
860860 if ( !LicenceDlg.exec () )
861861 {
862- Disconnect ();
862+ pClient-> Disconnect ();
863863 }
864864
865865 // unmute the client output stream if local mute button is not pressed
@@ -1164,7 +1164,7 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError )
11641164 // the sound device setup has a problem, disconnect any active connection
11651165 if ( pClient->IsRunning () )
11661166 {
1167- Disconnect ();
1167+ pClient-> Disconnect ();
11681168 }
11691169
11701170 // show the error message of the device setup
@@ -1193,65 +1193,36 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int
11931193 ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients );
11941194}
11951195
1196- void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel )
1196+ void CClientDlg::OnConnect ( const QString& strMixerBoardLabel )
11971197{
1198- // set address and check if address is valid
1199- if ( pClient->SetServerAddr ( strSelectedAddress ) )
1200- {
1201- // try to start client, if error occurred, do not go in
1202- // running state but show error message
1203- try
1204- {
1205- if ( !pClient->IsRunning () )
1206- {
1207- pClient->Start ();
1208- }
1209- }
12101198
1211- catch ( const CGenErr& generr )
1212- {
1213- // show error message and return the function
1214- QMessageBox::critical ( this , APP_NAME, generr.GetErrorText (), " Close" , nullptr );
1215- return ;
1216- }
1199+ // hide label connect to server
1200+ lblConnectToServer->hide ();
1201+ lbrInputLevelL->setEnabled ( true );
1202+ lbrInputLevelR->setEnabled ( true );
12171203
1218- // hide label connect to server
1219- lblConnectToServer->hide ();
1220- lbrInputLevelL->setEnabled ( true );
1221- lbrInputLevelR->setEnabled ( true );
1204+ // change connect button text to "disconnect"
1205+ butConnect->setText ( tr ( " &Disconnect" ) );
12221206
1223- // change connect button text to "disconnect"
1224- butConnect-> setText ( tr ( " &Disconnect " ) );
1207+ // set server name in audio mixer group box title
1208+ MainMixerBoard-> SetServerName ( strMixerBoardLabel );
12251209
1226- // set server name in audio mixer group box title
1227- MainMixerBoard->SetServerName ( strMixerBoardLabel );
1210+ // start timer for level meter bar and ping time measurement
1211+ TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1212+ TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1213+ TimerPing.start ( PING_UPDATE_TIME_MS );
1214+ TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
12281215
1229- // start timer for level meter bar and ping time measurement
1230- TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1231- TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1232- TimerPing.start ( PING_UPDATE_TIME_MS );
1233- TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
1234-
1235- // audio feedback detection
1236- if ( pSettings->bEnableFeedbackDetection )
1237- {
1238- TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1239- bDetectFeedback = true ;
1240- }
1216+ // audio feedback detection
1217+ if ( pSettings->bEnableFeedbackDetection )
1218+ {
1219+ TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1220+ bDetectFeedback = true ;
12411221 }
12421222}
12431223
1244- void CClientDlg::Disconnect ()
1224+ void CClientDlg::OnDisconnect ()
12451225{
1246- // only stop client if currently running, in case we received
1247- // the stopped message, the client is already stopped but the
1248- // connect/disconnect button and other GUI controls must be
1249- // updated
1250- if ( pClient->IsRunning () )
1251- {
1252- pClient->Stop ();
1253- }
1254-
12551226 // change connect button text to "connect"
12561227 butConnect->setText ( tr ( " C&onnect" ) );
12571228
@@ -1293,6 +1264,9 @@ void CClientDlg::Disconnect()
12931264
12941265 // clear mixer board (remove all faders)
12951266 MainMixerBoard->HideAll ();
1267+
1268+ // Reset the deco
1269+ SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
12961270}
12971271
12981272void CClientDlg::UpdateDisplay ()
0 commit comments