/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3613 by capela, Tue Oct 1 08:35:49 2019 UTC revision 3681 by capela, Thu Jan 2 14:39:02 2020 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007-2019 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 2792  void MainForm::timerSlot (void) Line 2792  void MainForm::timerSlot (void)
2792                                  }                                  }
2793                          }                          }
2794                  }                  }
2795    
2796            #if CONFIG_LSCP_CLIENT_CONNECTION_LOST
2797                    // If we lost connection to server: Try to automatically reconnect if we
2798                    // did not start the server.
2799                    //
2800                    // TODO: If we started the server, then we might inform the user that
2801                    // the server probably crashed and asking user ONCE whether we should
2802                    // restart the server.
2803                    if (lscp_client_connection_lost(m_pClient) && !m_pServer)
2804                            startAutoReconnectClient();
2805            #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST
2806          }          }
2807    
2808          // Register the next timer slot.          // Register the next timer slot.
# Line 2990  lscp_status_t qsampler_client_callback ( Line 3001  lscp_status_t qsampler_client_callback (
3001    
3002    
3003  // Start our almighty client...  // Start our almighty client...
3004  bool MainForm::startClient (void)  bool MainForm::startClient (bool bReconnectOnly)
3005  {  {
3006          // Have it a setup?          // Have it a setup?
3007          if (m_pOptions == nullptr)          if (m_pOptions == nullptr)
# Line 3011  bool MainForm::startClient (void) Line 3022  bool MainForm::startClient (void)
3022                  // Is this the first try?                  // Is this the first try?
3023                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3024                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
3025                          || !m_pOptions->bServerStart) {                          || !m_pOptions->bServerStart || bReconnectOnly)
3026                          appendMessagesError(                  {
3027                                  tr("Could not connect to server as client.\n\nSorry."));                          // if this method is called from autoReconnectClient()
3028                            // then don't bother user with an error message...
3029                            if (!bReconnectOnly) {
3030                                    appendMessagesError(
3031                                            tr("Could not connect to server as client.\n\nSorry.")
3032                                    );
3033                            }
3034                  } else {                  } else {
3035                          startServer();                          startServer();
3036                  }                  }
# Line 3142  void MainForm::stopClient (void) Line 3159  void MainForm::stopClient (void)
3159  }  }
3160    
3161    
3162    void MainForm::startAutoReconnectClient (void)
3163    {
3164            stopClient();
3165            appendMessages(tr("Trying to reconnect..."));
3166            QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3167    }
3168    
3169    
3170    void MainForm::autoReconnectClient (void)
3171    {
3172            const bool bSuccess = startClient(true);
3173            if (!bSuccess)
3174                    QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3175    }
3176    
3177    
3178  // Channel strip activation/selection.  // Channel strip activation/selection.
3179  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3180  {  {

Legend:
Removed from v.3613  
changed lines
  Added in v.3681

  ViewVC Help
Powered by ViewVC