/[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 3668 by schoenebeck, Sun Dec 22 13:47:40 2019 UTC revision 3685 by capela, Thu Jan 2 19:03:34 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 58  Line 58 
58  #include <QTimer>  #include <QTimer>
59  #include <QDateTime>  #include <QDateTime>
60    
61    #include <QElapsedTimer>
62    
63  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
64  #include <QMimeData>  #include <QMimeData>
65  #endif  #endif
# Line 2793  void MainForm::timerSlot (void) Line 2795  void MainForm::timerSlot (void)
2795                          }                          }
2796                  }                  }
2797    
2798  #if CONFIG_LSCP_CLIENT_CONNECTION_LOST          #if CONFIG_LSCP_CLIENT_CONNECTION_LOST
2799                  // If we lost connection to server: Try to automatically reconnect if we                  // If we lost connection to server: Try to automatically reconnect if we
2800                  // did not start the server.                  // did not start the server.
2801                  //                  //
# Line 2802  void MainForm::timerSlot (void) Line 2804  void MainForm::timerSlot (void)
2804                  // restart the server.                  // restart the server.
2805                  if (lscp_client_connection_lost(m_pClient) && !m_pServer)                  if (lscp_client_connection_lost(m_pClient) && !m_pServer)
2806                          startAutoReconnectClient();                          startAutoReconnectClient();
2807  #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST          #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST
2808          }          }
2809    
2810          // Register the next timer slot.          // Register the next timer slot.
# Line 2929  void MainForm::stopServer ( bool bIntera Line 2931  void MainForm::stopServer ( bool bIntera
2931    
2932          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2933          if (bGraceWait) {          if (bGraceWait) {
2934                  QTime t;                  QElapsedTimer timer;
2935                  t.start();                  timer.start();
2936                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
2937                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2938          }          }
2939  }  }
# Line 2961  void MainForm::processServerExit (void) Line 2963  void MainForm::processServerExit (void)
2963                          // Force final server shutdown...                          // Force final server shutdown...
2964                          m_pServer->kill();                          m_pServer->kill();
2965                          // Give it some time to terminate gracefully and stabilize...                          // Give it some time to terminate gracefully and stabilize...
2966                          QTime t;                          QElapsedTimer timer;
2967                          t.start();                          timer.start();
2968                          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                          while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
2969                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2970                  }                  }
2971                  // Force final server shutdown...                  // Force final server shutdown...
# Line 3024  bool MainForm::startClient (bool bReconn Line 3026  bool MainForm::startClient (bool bReconn
3026                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
3027                          || !m_pOptions->bServerStart || bReconnectOnly)                          || !m_pOptions->bServerStart || bReconnectOnly)
3028                  {                  {
3029                          // if this method is called from doAutoReconnect() then don't bother                          // if this method is called from autoReconnectClient()
3030                          // user with an error message                          // then don't bother user with an error message...
3031                          if (!bReconnectOnly) {                          if (!bReconnectOnly) {
3032                                  appendMessagesError(                                  appendMessagesError(
3033                                          tr("Could not connect to server as client.\n\nSorry.")                                          tr("Could not connect to server as client.\n\nSorry.")
# Line 3158  void MainForm::stopClient (void) Line 3160  void MainForm::stopClient (void)
3160          stabilizeForm();          stabilizeForm();
3161  }  }
3162    
3163  void MainForm::startAutoReconnectClient() {  
3164    void MainForm::startAutoReconnectClient (void)
3165    {
3166          stopClient();          stopClient();
3167          appendMessages("Trying to reconnect.");          appendMessages(tr("Trying to reconnect..."));
3168          QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient()));          QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3169  }  }
3170    
3171  void MainForm::doAutoReconnectClient() {  
3172          bool success = startClient(true);  void MainForm::autoReconnectClient (void)
3173          if (!success)  {
3174                  QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient()));          const bool bSuccess = startClient(true);
3175            if (!bSuccess)
3176                    QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3177  }  }
3178    
3179    

Legend:
Removed from v.3668  
changed lines
  Added in v.3685

  ViewVC Help
Powered by ViewVC