/[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 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 2792  void MainForm::timerSlot (void) Line 2794  void MainForm::timerSlot (void)
2794                                  }                                  }
2795                          }                          }
2796                  }                  }
2797    
2798            #if CONFIG_LSCP_CLIENT_CONNECTION_LOST
2799                    // If we lost connection to server: Try to automatically reconnect if we
2800                    // did not start the server.
2801                    //
2802                    // TODO: If we started the server, then we might inform the user that
2803                    // the server probably crashed and asking user ONCE whether we should
2804                    // restart the server.
2805                    if (lscp_client_connection_lost(m_pClient) && !m_pServer)
2806                            startAutoReconnectClient();
2807            #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST
2808          }          }
2809    
2810          // Register the next timer slot.          // Register the next timer slot.
# Line 2918  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 2950  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 2990  lscp_status_t qsampler_client_callback ( Line 3003  lscp_status_t qsampler_client_callback (
3003    
3004    
3005  // Start our almighty client...  // Start our almighty client...
3006  bool MainForm::startClient (void)  bool MainForm::startClient (bool bReconnectOnly)
3007  {  {
3008          // Have it a setup?          // Have it a setup?
3009          if (m_pOptions == nullptr)          if (m_pOptions == nullptr)
# Line 3011  bool MainForm::startClient (void) Line 3024  bool MainForm::startClient (void)
3024                  // Is this the first try?                  // Is this the first try?
3025                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3026                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
3027                          || !m_pOptions->bServerStart) {                          || !m_pOptions->bServerStart || bReconnectOnly)
3028                          appendMessagesError(                  {
3029                                  tr("Could not connect to server as client.\n\nSorry."));                          // if this method is called from autoReconnectClient()
3030                            // then don't bother user with an error message...
3031                            if (!bReconnectOnly) {
3032                                    appendMessagesError(
3033                                            tr("Could not connect to server as client.\n\nSorry.")
3034                                    );
3035                            }
3036                  } else {                  } else {
3037                          startServer();                          startServer();
3038                  }                  }
# Line 3142  void MainForm::stopClient (void) Line 3161  void MainForm::stopClient (void)
3161  }  }
3162    
3163    
3164    void MainForm::startAutoReconnectClient (void)
3165    {
3166            stopClient();
3167            appendMessages(tr("Trying to reconnect..."));
3168            QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3169    }
3170    
3171    
3172    void MainForm::autoReconnectClient (void)
3173    {
3174            const bool bSuccess = startClient(true);
3175            if (!bSuccess)
3176                    QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3177    }
3178    
3179    
3180  // Channel strip activation/selection.  // Channel strip activation/selection.
3181  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3182  {  {

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

  ViewVC Help
Powered by ViewVC