@@ -277,7 +277,12 @@ 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+ 
283+         pClient->Connect  ( strConnOnStartupAddress, strConnOnStartupAddress );
284+         //  TODO: Find out why without this the mixer status issue still occurs. 
285+         OnConnect  ( strConnOnStartupAddress );
281286    }
282287
283288    //  File menu  --------------------------------------------------------------
@@ -473,7 +478,11 @@ CClientDlg::CClientDlg ( CClient*         pNCliP,
473478    //  other
474479    QObject::connect  ( pClient, &CClient::ConClientListMesReceived, this , &CClientDlg::OnConClientListMesReceived );
475480
476-     QObject::connect  ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnected );
481+     QObject::connect  ( pClient, &CClient::Connecting, this , &CClientDlg::OnConnect );
482+ 
483+     QObject::connect  ( pClient, &CClient::ConnectingFailed, this , &CClientDlg::OnConnectingFailed );
484+ 
485+     QObject::connect  ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnect );
477486
478487    QObject::connect  ( pClient, &CClient::ChatTextReceived, this , &CClientDlg::OnChatTextReceived );
479488
@@ -608,11 +617,8 @@ void CClientDlg::closeEvent ( QCloseEvent* Event )
608617    ConnectDlg.close ();
609618    AnalyzerConsole.close ();
610619
611-     //  if connected, terminate connection
612-     if  ( pClient->IsRunning () )
613-     {
614-         pClient->Stop ();
615-     }
620+     //  Disconnect if needed
621+     pClient->Disconnect ();
616622
617623    //  make sure all current fader settings are applied to the settings struct
618624    MainMixerBoard->StoreAllFaderSettings ();
@@ -730,15 +736,9 @@ void CClientDlg::OnConnectDlgAccepted()
730736            }
731737        }
732738
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 () )
736-         {
737-             Disconnect ();
738-         }
739- 
740739        //  initiate connection
741-         Connect  ( strSelectedAddress, strMixerBoardLabel );
740+ 
741+         pClient->Connect  ( strSelectedAddress, strMixerBoardLabel );
742742
743743        //  reset flag
744744        bConnectDlgWasShown = false ;
@@ -750,11 +750,12 @@ void CClientDlg::OnConnectDisconBut()
750750    //  the connect/disconnect button implements a toggle functionality
751751    if  ( pClient->IsRunning () )
752752    {
753-         Disconnect ();
754-         SetMixerBoardDeco  ( RS_UNDEFINED, pClient->GetGUIDesign () );
753+         pClient->Disconnect ();
755754    }
756755    else 
757756    {
757+         //  If the client isn't running, we assume that we weren't connected. Thus show the connect dialog
758+         //  TODO: Refactor to have robust error handling
758759        ShowConnectionSetupDialog ();
759760    }
760761}
@@ -859,7 +860,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType )
859860        //  disconnect from that server.
860861        if  ( !LicenceDlg.exec () )
861862        {
862-             Disconnect ();
863+             pClient-> Disconnect ();
863864        }
864865
865866        //  unmute the client output stream if local mute button is not pressed
@@ -1164,7 +1165,7 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError )
11641165        //  the sound device setup has a problem, disconnect any active connection
11651166        if  ( pClient->IsRunning () )
11661167        {
1167-             Disconnect ();
1168+             pClient-> Disconnect ();
11681169        }
11691170
11701171        //  show the error message of the device setup
@@ -1193,65 +1194,41 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int
11931194    ConnectDlg.SetPingTimeAndNumClientsResult  ( InetAddr, iPingTime, iNumClients );
11941195}
11951196
1196- void  CClientDlg::Connect   (  const  QString& strSelectedAddress,  const  QString& strMixerBoardLabel )
1197+ void  CClientDlg::OnConnect   (  const  QString& strMixerBoardLabel )
11971198{
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-         }
1210- 
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-         }
12171199
1218-          //  hide label connect to server
1219-          lblConnectToServer->hide ();
1220-          lbrInputLevelL->setEnabled  ( true  );
1221-          lbrInputLevelR->setEnabled  ( true  );
1200+     //  hide label connect to server
1201+     lblConnectToServer->hide ();
1202+     lbrInputLevelL->setEnabled  ( true  );
1203+     lbrInputLevelR->setEnabled  ( true  );
12221204
1223-          //  change connect button text to "disconnect"
1224-          butConnect->setText  ( tr  ( " &Disconnect"   ) );
1205+     //  change connect button text to "disconnect"
1206+     butConnect->setText  ( tr  ( " &Disconnect"   ) );
12251207
1226-          //  set server name in audio mixer group box title
1227-          MainMixerBoard->SetServerName  ( strMixerBoardLabel );
1208+     //  set server name in audio mixer group box title
1209+     MainMixerBoard->SetServerName  ( strMixerBoardLabel );
12281210
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
1211+     //  start timer for level meter bar and ping time measurement
1212+     TimerSigMet.start  ( LEVELMETER_UPDATE_TIME_MS );
1213+     TimerBuffersLED.start  ( BUFFER_LED_UPDATE_TIME_MS );
1214+     TimerPing.start  ( PING_UPDATE_TIME_MS );
1215+     TimerCheckAudioDeviceOk.start  ( CHECK_AUDIO_DEV_OK_TIME_MS ); //  is single shot timer
12341216
1235-         //  audio feedback detection
1236-         if  ( pSettings->bEnableFeedbackDetection  )
1237-         {
1238-             TimerDetectFeedback.start  ( DETECT_FEEDBACK_TIME_MS ); //  single shot timer
1239-             bDetectFeedback = true ;
1240-         }
1217+     //  audio feedback detection
1218+     if  ( pSettings->bEnableFeedbackDetection  )
1219+     {
1220+         TimerDetectFeedback.start  ( DETECT_FEEDBACK_TIME_MS ); //  single shot timer
1221+         bDetectFeedback = true ;
12411222    }
12421223}
12431224
1244- void  CClientDlg::Disconnect  ( )
1225+ void  CClientDlg::OnConnectingFailed   (  const  QString& strError  )
12451226{
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-     }
1227+     QMessageBox::critical  ( this , APP_NAME, strError, " Close"  , nullptr  );
1228+ }
12541229
1230+ void  CClientDlg::OnDisconnect ()
1231+ {
12551232    //  change connect button text to "connect"
12561233    butConnect->setText  ( tr  ( " C&onnect"   ) );
12571234
@@ -1293,6 +1270,9 @@ void CClientDlg::Disconnect()
12931270
12941271    //  clear mixer board (remove all faders)
12951272    MainMixerBoard->HideAll ();
1273+ 
1274+     //  Reset the deco
1275+     SetMixerBoardDeco  ( RS_UNDEFINED, pClient->GetGUIDesign () );
12961276}
12971277
12981278void  CClientDlg::UpdateDisplay ()
0 commit comments