/[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 3357 by capela, Tue Oct 17 21:44:20 2017 UTC revision 3613 by capela, Tue Oct 1 08:35:49 2019 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2017, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007,2008,2015 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
# Line 58  Line 58 
58  #include <QTimer>  #include <QTimer>
59  #include <QDateTime>  #include <QDateTime>
60    
61  #if QT_VERSION >= 0x050000  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
62  #include <QMimeData>  #include <QMimeData>
63  #endif  #endif
64    
65  #if QT_VERSION < 0x040500  #if QT_VERSION < QT_VERSION_CHECK(4, 5, 0)
66  namespace Qt {  namespace Qt {
67  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
68  }  }
69  #endif  #endif
70    
 #ifdef HAVE_SIGNAL_H  
 #include <signal.h>  
 #endif  
   
71  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
72  #include <gig.h>  #include <gig.h>
73  #endif  #endif
# Line 91  static inline long lroundf ( float x ) Line 87  static inline long lroundf ( float x )
87    
88    
89  // All winsock apps needs this.  // All winsock apps needs this.
90  #if defined(_WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
91  static WSADATA _wsaData;  static WSADATA _wsaData;
92    #undef HAVE_SIGNAL_H
93  #endif  #endif
94    
95    
# Line 103  static WSADATA _wsaData; Line 100  static WSADATA _wsaData;
100    
101  #include <QSocketNotifier>  #include <QSocketNotifier>
102    
103    #include <unistd.h>
104  #include <sys/types.h>  #include <sys/types.h>
105  #include <sys/socket.h>  #include <sys/socket.h>
   
106  #include <signal.h>  #include <signal.h>
107    
108  // File descriptor for SIGUSR1 notifier.  // File descriptor for SIGUSR1 notifier.
109  static int g_fdUsr1[2];  static int g_fdSigusr1[2] = { -1, -1 };
110    
111  // Unix SIGUSR1 signal handler.  // Unix SIGUSR1 signal handler.
112  static void qsampler_sigusr1_handler ( int /* signo */ )  static void qsampler_sigusr1_handler ( int /* signo */ )
113  {  {
114          char c = 1;          char c = 1;
115    
116          (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);          (::write(g_fdSigusr1[0], &c, sizeof(c)) > 0);
117    }
118    
119    // File descriptor for SIGTERM notifier.
120    static int g_fdSigterm[2] = { -1, -1 };
121    
122    // Unix SIGTERM signal handler.
123    static void qsampler_sigterm_handler ( int /* signo */ )
124    {
125            char c = 1;
126    
127            (::write(g_fdSigterm[0], &c, sizeof(c)) > 0);
128  }  }
129    
130  #endif  // HAVE_SIGNAL_H  #endif  // HAVE_SIGNAL_H
# Line 194  protected: Line 202  protected:
202  // QSampler::MainForm -- Main window form implementation.  // QSampler::MainForm -- Main window form implementation.
203    
204  // Kind of singleton reference.  // Kind of singleton reference.
205  MainForm *MainForm::g_pMainForm = NULL;  MainForm *MainForm::g_pMainForm = nullptr;
206    
207  MainForm::MainForm ( QWidget *pParent )  MainForm::MainForm ( QWidget *pParent )
208          : QMainWindow(pParent)          : QMainWindow(pParent)
# Line 205  MainForm::MainForm ( QWidget *pParent ) Line 213  MainForm::MainForm ( QWidget *pParent )
213          g_pMainForm = this;          g_pMainForm = this;
214    
215          // Initialize some pointer references.          // Initialize some pointer references.
216          m_pOptions = NULL;          m_pOptions = nullptr;
217    
218          // All child forms are to be created later, not earlier than setup.          // All child forms are to be created later, not earlier than setup.
219          m_pMessages = NULL;          m_pMessages = nullptr;
220          m_pInstrumentListForm = NULL;          m_pInstrumentListForm = nullptr;
221          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
222    
223          // We'll start clean.          // We'll start clean.
224          m_iUntitled   = 0;          m_iUntitled   = 0;
225          m_iDirtySetup = 0;          m_iDirtySetup = 0;
226          m_iDirtyCount = 0;          m_iDirtyCount = 0;
227    
228          m_pServer = NULL;          m_pServer = nullptr;
229          m_pClient = NULL;          m_pClient = nullptr;
230    
231          m_iStartDelay = 0;          m_iStartDelay = 0;
232          m_iTimerDelay = 0;          m_iTimerDelay = 0;
# Line 233  MainForm::MainForm ( QWidget *pParent ) Line 241  MainForm::MainForm ( QWidget *pParent )
241          // LADISH Level 1 suport.          // LADISH Level 1 suport.
242    
243          // Initialize file descriptors for SIGUSR1 socket notifier.          // Initialize file descriptors for SIGUSR1 socket notifier.
244          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigusr1);
245          m_pUsr1Notifier          m_pSigusr1Notifier
246                  = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);                  = new QSocketNotifier(g_fdSigusr1[1], QSocketNotifier::Read, this);
247    
248          QObject::connect(m_pUsr1Notifier,          QObject::connect(m_pSigusr1Notifier,
249                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
250                  SLOT(handle_sigusr1()));                  SLOT(handle_sigusr1()));
251    
252          // Install SIGUSR1 signal handler.          // Install SIGUSR1 signal handler.
253      struct sigaction usr1;          struct sigaction sigusr1;
254      usr1.sa_handler = qsampler_sigusr1_handler;          sigusr1.sa_handler = qsampler_sigusr1_handler;
255      sigemptyset(&usr1.sa_mask);          sigemptyset(&sigusr1.sa_mask);
256      usr1.sa_flags = 0;          sigusr1.sa_flags = 0;
257      usr1.sa_flags |= SA_RESTART;          sigusr1.sa_flags |= SA_RESTART;
258      ::sigaction(SIGUSR1, &usr1, NULL);          ::sigaction(SIGUSR1, &sigusr1, nullptr);
259    
260            // Initialize file descriptors for SIGTERM socket notifier.
261            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);
262            m_pSigtermNotifier
263                    = new QSocketNotifier(g_fdSigterm[1], QSocketNotifier::Read, this);
264    
265            QObject::connect(m_pSigtermNotifier,
266                    SIGNAL(activated(int)),
267                    SLOT(handle_sigterm()));
268    
269            // Install SIGTERM signal handler.
270            struct sigaction sigterm;
271            sigterm.sa_handler = qsampler_sigterm_handler;
272            sigemptyset(&sigterm.sa_mask);
273            sigterm.sa_flags = 0;
274            sigterm.sa_flags |= SA_RESTART;
275            ::sigaction(SIGTERM, &sigterm, nullptr);
276            ::sigaction(SIGQUIT, &sigterm, nullptr);
277    
278            // Ignore SIGHUP/SIGINT signals.
279            ::signal(SIGHUP, SIG_IGN);
280            ::signal(SIGINT, SIG_IGN);
281    
282  #else   // HAVE_SIGNAL_H  #else   // HAVE_SIGNAL_H
283    
284          m_pUsr1Notifier = NULL;          m_pSigusr1Notifier = nullptr;
285            m_pSigtermNotifier = nullptr;
286                    
287  #endif  // !HAVE_SIGNAL_H  #endif  // !HAVE_SIGNAL_H
288    
# Line 324  MainForm::MainForm ( QWidget *pParent ) Line 355  MainForm::MainForm ( QWidget *pParent )
355          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
356          statusBar()->addWidget(pLabel);          statusBar()->addWidget(pLabel);
357    
358  #if defined(_WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
359          WSAStartup(MAKEWORD(1, 1), &_wsaData);          WSAStartup(MAKEWORD(1, 1), &_wsaData);
360  #endif  #endif
361    
# Line 425  MainForm::~MainForm() Line 456  MainForm::~MainForm()
456          // Do final processing anyway.          // Do final processing anyway.
457          processServerExit();          processServerExit();
458    
459  #if defined(_WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
460          WSACleanup();          WSACleanup();
461  #endif  #endif
462    
463  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
464          if (m_pUsr1Notifier)          if (m_pSigusr1Notifier)
465                  delete m_pUsr1Notifier;                  delete m_pSigusr1Notifier;
466            if (m_pSigtermNotifier)
467                    delete m_pSigtermNotifier;
468  #endif  #endif
469    
470          // Finally drop any widgets around...          // Finally drop any widgets around...
# Line 460  MainForm::~MainForm() Line 493  MainForm::~MainForm()
493  #endif  #endif
494    
495          // Pseudo-singleton reference shut-down.          // Pseudo-singleton reference shut-down.
496          g_pMainForm = NULL;          g_pMainForm = nullptr;
497  }  }
498    
499    
# Line 597  void MainForm::closeEvent ( QCloseEvent Line 630  void MainForm::closeEvent ( QCloseEvent
630  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
631  {  {
632          // Accept external drags only...          // Accept external drags only...
633          if (pDragEnterEvent->source() == NULL          if (pDragEnterEvent->source() == nullptr
634                  && pDragEnterEvent->mimeData()->hasUrls()) {                  && pDragEnterEvent->mimeData()->hasUrls()) {
635                  pDragEnterEvent->accept();                  pDragEnterEvent->accept();
636          } else {          } else {
# Line 621  void MainForm::dropEvent ( QDropEvent *p Line 654  void MainForm::dropEvent ( QDropEvent *p
654                          if (QFileInfo(sPath).exists()) {                          if (QFileInfo(sPath).exists()) {
655                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
656                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
657                                  if (pChannel == NULL)                                  if (pChannel == nullptr)
658                                          return;                                          return;
659                                  // Start setting the instrument filename...                                  // Start setting the instrument filename...
660                                  pChannel->setInstrument(sPath, 0);                                  pChannel->setInstrument(sPath, 0);
# Line 721  void MainForm::handle_sigusr1 (void) Line 754  void MainForm::handle_sigusr1 (void)
754    
755          char c;          char c;
756    
757          if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)          if (::read(g_fdSigusr1[1], &c, sizeof(c)) > 0)
758                  saveSession(false);                  saveSession(false);
759    
760  #endif  #endif
761  }  }
762    
763    
764    void MainForm::handle_sigterm (void)
765    {
766    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
767    
768            char c;
769    
770            if (::read(g_fdSigterm[1], &c, sizeof(c)) > 0)
771                    close();
772    
773    #endif
774    }
775    
776    
777  void MainForm::updateViewMidiDeviceStatusMenu (void)  void MainForm::updateViewMidiDeviceStatusMenu (void)
778  {  {
779          m_ui.viewMidiDeviceStatusMenu->clear();          m_ui.viewMidiDeviceStatusMenu->clear();
# Line 806  bool MainForm::newSession (void) Line 852  bool MainForm::newSession (void)
852          m_iUntitled++;          m_iUntitled++;
853    
854          // Stabilize form.          // Stabilize form.
855          m_sFilename = QString::null;          m_sFilename = QString();
856          m_iDirtyCount = 0;          m_iDirtyCount = 0;
857          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));
858          stabilizeForm();          stabilizeForm();
# Line 818  bool MainForm::newSession (void) Line 864  bool MainForm::newSession (void)
864  // Open an existing sampler session.  // Open an existing sampler session.
865  bool MainForm::openSession (void)  bool MainForm::openSession (void)
866  {  {
867          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
868                  return false;                  return false;
869    
870          // Ask for the filename to open...          // Ask for the filename to open...
871          QString sFilename = QFileDialog::getOpenFileName(this,          QString sFilename = QFileDialog::getOpenFileName(this,
872                  QSAMPLER_TITLE ": " + tr("Open Session"), // Caption.                  tr("Open Session"),                       // Caption.
873                  m_pOptions->sSessionDir,                  // Start here.                  m_pOptions->sSessionDir,                  // Start here.
874                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
875          );          );
# Line 844  bool MainForm::openSession (void) Line 890  bool MainForm::openSession (void)
890  // Save current sampler session with another name.  // Save current sampler session with another name.
891  bool MainForm::saveSession ( bool bPrompt )  bool MainForm::saveSession ( bool bPrompt )
892  {  {
893          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
894                  return false;                  return false;
895    
896          QString sFilename = m_sFilename;          QString sFilename = m_sFilename;
# Line 856  bool MainForm::saveSession ( bool bPromp Line 902  bool MainForm::saveSession ( bool bPromp
902                          sFilename = m_pOptions->sSessionDir;                          sFilename = m_pOptions->sSessionDir;
903                  // Prompt the guy...                  // Prompt the guy...
904                  sFilename = QFileDialog::getSaveFileName(this,                  sFilename = QFileDialog::getSaveFileName(this,
905                          QSAMPLER_TITLE ": " + tr("Save Session"), // Caption.                          tr("Save Session"),                       // Caption.
906                          sFilename,                                // Start here.                          sFilename,                                // Start here.
907                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
908                  );                  );
# Line 866  bool MainForm::saveSession ( bool bPromp Line 912  bool MainForm::saveSession ( bool bPromp
912                  // Enforce .lscp extension...                  // Enforce .lscp extension...
913                  if (QFileInfo(sFilename).suffix().isEmpty())                  if (QFileInfo(sFilename).suffix().isEmpty())
914                          sFilename += ".lscp";                          sFilename += ".lscp";
915            #if 0
916                  // Check if already exists...                  // Check if already exists...
917                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
918                          if (QMessageBox::warning(this,                          if (QMessageBox::warning(this,
919                                  QSAMPLER_TITLE ": " + tr("Warning"),                                  tr("Warning"),
920                                  tr("The file already exists:\n\n"                                  tr("The file already exists:\n\n"
921                                  "\"%1\"\n\n"                                  "\"%1\"\n\n"
922                                  "Do you want to replace it?")                                  "Do you want to replace it?")
# Line 878  bool MainForm::saveSession ( bool bPromp Line 925  bool MainForm::saveSession ( bool bPromp
925                                  == QMessageBox::No)                                  == QMessageBox::No)
926                                  return false;                                  return false;
927                  }                  }
928            #endif
929          }          }
930    
931          // Save it right away.          // Save it right away.
# Line 893  bool MainForm::closeSession ( bool bForc Line 941  bool MainForm::closeSession ( bool bForc
941          // Are we dirty enough to prompt it?          // Are we dirty enough to prompt it?
942          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
943                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
944                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
945                          tr("The current session has been changed:\n\n"                          tr("The current session has been changed:\n\n"
946                          "\"%1\"\n\n"                          "\"%1\"\n\n"
947                          "Do you want to save the changes?")                          "Do you want to save the changes?")
# Line 918  bool MainForm::closeSession ( bool bForc Line 966  bool MainForm::closeSession ( bool bForc
966                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
967                  const QList<QMdiSubWindow *>& wlist                  const QList<QMdiSubWindow *>& wlist
968                          = m_pWorkspace->subWindowList();                          = m_pWorkspace->subWindowList();
969                  const int iStripCount = wlist.count();                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
970                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                          ChannelStrip *pChannelStrip
971                          ChannelStrip *pChannelStrip = NULL;                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
972                          if (pChannelStrip) {                          if (pChannelStrip) {
973                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
974                                  if (bForce && pChannel)                                  if (bForce && pChannel)
975                                          pChannel->removeChannel();                                          pChannel->removeChannel();
976                                  delete pChannelStrip;                                  delete pChannelStrip;
977                          }                          }
978                          if (pMdiSubWindow)                          delete pMdiSubWindow;
                                 delete pMdiSubWindow;  
979                  }                  }
980                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
981                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 945  bool MainForm::closeSession ( bool bForc Line 989  bool MainForm::closeSession ( bool bForc
989  // Load a session from specific file path.  // Load a session from specific file path.
990  bool MainForm::loadSessionFile ( const QString& sFilename )  bool MainForm::loadSessionFile ( const QString& sFilename )
991  {  {
992          if (m_pClient == NULL)          if (m_pClient == nullptr)
993                  return false;                  return false;
994    
995          // Open and read from real file.          // Open and read from real file.
# Line 1021  bool MainForm::loadSessionFile ( const Q Line 1065  bool MainForm::loadSessionFile ( const Q
1065  // Save current session to specific file path.  // Save current session to specific file path.
1066  bool MainForm::saveSessionFile ( const QString& sFilename )  bool MainForm::saveSessionFile ( const QString& sFilename )
1067  {  {
1068          if (m_pClient == NULL)          if (m_pClient == nullptr)
1069                  return false;                  return false;
1070    
1071          // Check whether server is apparently OK...          // Check whether server is apparently OK...
# Line 1060  bool MainForm::saveSessionFile ( const Q Line 1104  bool MainForm::saveSessionFile ( const Q
1104          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
1105          // will be loaded from a complete initialized server...          // will be loaded from a complete initialized server...
1106          int *piDeviceIDs;          int *piDeviceIDs;
1107          int  iDevice;          int  i, iDevice;
1108          ts << "RESET" << endl;          ts << "RESET" << endl;
1109    
1110          // Audio device mapping.          // Audio device mapping.
1111          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap; iDevice = 0;
1112          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);
1113          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1114                  ts << endl;                  Device device(Device::Audio, piDeviceIDs[i]);
1115                  Device device(Device::Audio, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1116                    if (device.driverName().toUpper() == "PLUGIN")
1117                            continue;
1118                  // Audio device specification...                  // Audio device specification...
1119                    ts << endl;
1120                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1121                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1122                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
# Line 1100  bool MainForm::saveSessionFile ( const Q Line 1147  bool MainForm::saveSessionFile ( const Q
1147                          iPort++;                          iPort++;
1148                  }                  }
1149                  // Audio device index/id mapping.                  // Audio device index/id mapping.
1150                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap.insert(device.deviceID(), iDevice++);
1151                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1152                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1153          }          }
1154    
1155          // MIDI device mapping.          // MIDI device mapping.
1156          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap; iDevice = 0;
1157          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);
1158          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1159                  ts << endl;                  Device device(Device::Midi, piDeviceIDs[i]);
1160                  Device device(Device::Midi, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1161                    if (device.driverName().toUpper() == "PLUGIN")
1162                            continue;
1163                  // MIDI device specification...                  // MIDI device specification...
1164                    ts << endl;
1165                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1166                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1167                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
# Line 1142  bool MainForm::saveSessionFile ( const Q Line 1192  bool MainForm::saveSessionFile ( const Q
1192                          iPort++;                          iPort++;
1193                  }                  }
1194                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
1195                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap.insert(device.deviceID(), iDevice++);
1196                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1197                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1198          }          }
# Line 1205  bool MainForm::saveSessionFile ( const Q Line 1255  bool MainForm::saveSessionFile ( const Q
1255                  }                  }
1256                  ts << endl;                  ts << endl;
1257                  // Check for errors...                  // Check for errors...
1258                  if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) {                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {
1259                          appendMessagesClient("lscp_list_midi_instruments");                          appendMessagesClient("lscp_list_midi_instruments");
1260                          iErrors++;                          iErrors++;
1261                  }                  }
1262                  // MIDI strument index/id mapping.                  // MIDI strument index/id mapping.
1263                  midiInstrumentMap[iMidiMap] = iMap;                  midiInstrumentMap.insert(iMidiMap, iMap);
1264          }          }
1265          // Check for errors...          // Check for errors...
1266          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {          if (piMaps == nullptr && ::lscp_client_get_errno(m_pClient)) {
1267                  appendMessagesClient("lscp_list_midi_instrument_maps");                  appendMessagesClient("lscp_list_midi_instrument_maps");
1268                  iErrors++;                  iErrors++;
1269          }          }
1270  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1271    
1272          // Sampler channel mapping.          // Sampler channel mapping...
1273            int iChannelID = 0;
1274          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1275                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1276          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1277          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1278                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1279                  if (pChannelStrip) {                  if (pChannelStrip) {
1280                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1281                          if (pChannel) {                          if (pChannel) {
1282                                  const int iChannelID = pChannel->channelID();                                  // Avoid "artifial" plug-in devices...
1283                                    const int iAudioDevice = pChannel->audioDevice();
1284                                    if (!audioDeviceMap.contains(iAudioDevice))
1285                                            continue;
1286                                    const int iMidiDevice = pChannel->midiDevice();
1287                                    if (!midiDeviceMap.contains(iMidiDevice))
1288                                            continue;
1289                                    // Go for regular, canonical devices...
1290                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;
1291                                  ts << "ADD CHANNEL" << endl;                                  ts << "ADD CHANNEL" << endl;
1292                                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
# Line 1239  bool MainForm::saveSessionFile ( const Q Line 1294  bool MainForm::saveSessionFile ( const Q
1294                                                  << " " << pChannel->audioDriver() << endl;                                                  << " " << pChannel->audioDriver() << endl;
1295                                  } else {                                  } else {
1296                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID
1297                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;                                                  << " " << audioDeviceMap.value(iAudioDevice) << endl;
1298                                  }                                  }
1299                                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
1300                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID
1301                                                  << " " << pChannel->midiDriver() << endl;                                                  << " " << pChannel->midiDriver() << endl;
1302                                  } else {                                  } else {
1303                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID
1304                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;                                                  << " " << midiDeviceMap.value(iMidiDevice) << endl;
1305                                  }                                  }
1306                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID
1307                                          << " " << pChannel->midiPort() << endl;                                          << " " << pChannel->midiPort() << endl;
# Line 1277  bool MainForm::saveSessionFile ( const Q Line 1332  bool MainForm::saveSessionFile ( const Q
1332                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1333                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;
1334                          #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1335                                  if (pChannel->midiMap() >= 0) {                                  const int iMidiMap = pChannel->midiMap();
1336                                    if (midiInstrumentMap.contains(iMidiMap)) {
1337                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID
1338                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap.value(iMidiMap) << endl;
1339                                  }                                  }
1340                          #endif                          #endif
1341                          #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
# Line 1318  bool MainForm::saveSessionFile ( const Q Line 1374  bool MainForm::saveSessionFile ( const Q
1374                                  }                                  }
1375                          #endif                          #endif
1376                                  ts << endl;                                  ts << endl;
1377                                    // Go for next channel...
1378                                    ++iChannelID;
1379                          }                          }
1380                  }                  }
1381                  // Try to keep it snappy :)                  // Try to keep it snappy :)
# Line 1423  void MainForm::fileSaveAs (void) Line 1481  void MainForm::fileSaveAs (void)
1481  // Reset the sampler instance.  // Reset the sampler instance.
1482  void MainForm::fileReset (void)  void MainForm::fileReset (void)
1483  {  {
1484          if (m_pClient == NULL)          if (m_pClient == nullptr)
1485                  return;                  return;
1486    
1487          // Ask user whether he/she want's an internal sampler reset...          // Ask user whether he/she want's an internal sampler reset...
1488          if (m_pOptions && m_pOptions->bConfirmReset) {          if (m_pOptions && m_pOptions->bConfirmReset) {
1489                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1490                  const QString& sText = tr(                  const QString& sText = tr(
1491                          "Resetting the sampler instance will close\n"                          "Resetting the sampler instance will close\n"
1492                          "all device and channel configurations.\n\n"                          "all device and channel configurations.\n\n"
# Line 1479  void MainForm::fileReset (void) Line 1537  void MainForm::fileReset (void)
1537  // Restart the client/server instance.  // Restart the client/server instance.
1538  void MainForm::fileRestart (void)  void MainForm::fileRestart (void)
1539  {  {
1540          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1541                  return;                  return;
1542    
1543          bool bRestart = true;          bool bRestart = true;
# Line 1487  void MainForm::fileRestart (void) Line 1545  void MainForm::fileRestart (void)
1545          // Ask user whether he/she want's a complete restart...          // Ask user whether he/she want's a complete restart...
1546          // (if we're currently up and running)          // (if we're currently up and running)
1547          if (m_pOptions && m_pOptions->bConfirmRestart) {          if (m_pOptions && m_pOptions->bConfirmRestart) {
1548                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1549                  const QString& sText = tr(                  const QString& sText = tr(
1550                          "New settings will be effective after\n"                          "New settings will be effective after\n"
1551                          "restarting the client/server connection.\n\n"                          "restarting the client/server connection.\n\n"
# Line 1547  void MainForm::editAddChannel (void) Line 1605  void MainForm::editAddChannel (void)
1605    
1606  void MainForm::addChannelStrip (void)  void MainForm::addChannelStrip (void)
1607  {  {
1608          if (m_pClient == NULL)          if (m_pClient == nullptr)
1609                  return;                  return;
1610    
1611          // Just create the channel instance...          // Just create the channel instance...
1612          Channel *pChannel = new Channel();          Channel *pChannel = new Channel();
1613          if (pChannel == NULL)          if (pChannel == nullptr)
1614                  return;                  return;
1615    
1616          // Before we show it up, may be we'll          // Before we show it up, may be we'll
# Line 1588  void MainForm::editRemoveChannel (void) Line 1646  void MainForm::editRemoveChannel (void)
1646    
1647  void MainForm::removeChannelStrip (void)  void MainForm::removeChannelStrip (void)
1648  {  {
1649          if (m_pClient == NULL)          if (m_pClient == nullptr)
1650                  return;                  return;
1651    
1652          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1653          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1654                  return;                  return;
1655    
1656          Channel *pChannel = pChannelStrip->channel();          Channel *pChannel = pChannelStrip->channel();
1657          if (pChannel == NULL)          if (pChannel == nullptr)
1658                  return;                  return;
1659    
1660          // Prompt user if he/she's sure about this...          // Prompt user if he/she's sure about this...
1661          if (m_pOptions && m_pOptions->bConfirmRemove) {          if (m_pOptions && m_pOptions->bConfirmRemove) {
1662                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1663                  const QString& sText = tr(                  const QString& sText = tr(
1664                          "About to remove channel:\n\n"                          "About to remove channel:\n\n"
1665                          "%1\n\n"                          "%1\n\n"
# Line 1644  void MainForm::removeChannelStrip (void) Line 1702  void MainForm::removeChannelStrip (void)
1702  // Setup current sampler channel.  // Setup current sampler channel.
1703  void MainForm::editSetupChannel (void)  void MainForm::editSetupChannel (void)
1704  {  {
1705          if (m_pClient == NULL)          if (m_pClient == nullptr)
1706                  return;                  return;
1707    
1708          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1709          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1710                  return;                  return;
1711    
1712          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1659  void MainForm::editSetupChannel (void) Line 1717  void MainForm::editSetupChannel (void)
1717  // Edit current sampler channel.  // Edit current sampler channel.
1718  void MainForm::editEditChannel (void)  void MainForm::editEditChannel (void)
1719  {  {
1720          if (m_pClient == NULL)          if (m_pClient == nullptr)
1721                  return;                  return;
1722    
1723          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1724          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1725                  return;                  return;
1726    
1727          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1674  void MainForm::editEditChannel (void) Line 1732  void MainForm::editEditChannel (void)
1732  // Reset current sampler channel.  // Reset current sampler channel.
1733  void MainForm::editResetChannel (void)  void MainForm::editResetChannel (void)
1734  {  {
1735          if (m_pClient == NULL)          if (m_pClient == nullptr)
1736                  return;                  return;
1737    
1738          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1739          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1740                  return;                  return;
1741    
1742          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1689  void MainForm::editResetChannel (void) Line 1747  void MainForm::editResetChannel (void)
1747  // Reset all sampler channels.  // Reset all sampler channels.
1748  void MainForm::editResetAllChannels (void)  void MainForm::editResetAllChannels (void)
1749  {  {
1750          if (m_pClient == NULL)          if (m_pClient == nullptr)
1751                  return;                  return;
1752    
1753          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
# Line 1697  void MainForm::editResetAllChannels (voi Line 1755  void MainForm::editResetAllChannels (voi
1755          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1756          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1757                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1758          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1759          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1760                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1761                  if (pChannelStrip)                  if (pChannelStrip)
1762                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1763          }          }
# Line 1761  void MainForm::viewMessages ( bool bOn ) Line 1816  void MainForm::viewMessages ( bool bOn )
1816  // Show/hide the MIDI instrument list-view form.  // Show/hide the MIDI instrument list-view form.
1817  void MainForm::viewInstruments (void)  void MainForm::viewInstruments (void)
1818  {  {
1819          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1820                  return;                  return;
1821    
1822          if (m_pInstrumentListForm) {          if (m_pInstrumentListForm) {
# Line 1780  void MainForm::viewInstruments (void) Line 1835  void MainForm::viewInstruments (void)
1835  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1836  void MainForm::viewDevices (void)  void MainForm::viewDevices (void)
1837  {  {
1838          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1839                  return;                  return;
1840    
1841          if (m_pDeviceForm) {          if (m_pDeviceForm) {
# Line 1799  void MainForm::viewDevices (void) Line 1854  void MainForm::viewDevices (void)
1854  // Show options dialog.  // Show options dialog.
1855  void MainForm::viewOptions (void)  void MainForm::viewOptions (void)
1856  {  {
1857          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1858                  return;                  return;
1859    
1860          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
# Line 1841  void MainForm::viewOptions (void) Line 1896  void MainForm::viewOptions (void)
1896                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||
1897                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {
1898                                  QMessageBox::information(this,                                  QMessageBox::information(this,
1899                                          QSAMPLER_TITLE ": " + tr("Information"),                                          tr("Information"),
1900                                          tr("Some settings may be only effective\n"                                          tr("Some settings may be only effective\n"
1901                                          "next time you start this program."));                                          "next time you start this program."));
1902                                  updateMessagesCapture();                                  updateMessagesCapture();
# Line 1905  void MainForm::channelsArrange (void) Line 1960  void MainForm::channelsArrange (void)
1960    
1961          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1962          int y = 0;          int y = 0;
1963          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1964          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  pMdiSubWindow->adjustSize();
1965                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  const QRect& frameRect
1966                  if (pMdiSubWindow) {                          = pMdiSubWindow->frameGeometry();
1967                          pMdiSubWindow->adjustSize();                  int w = m_pWorkspace->width();
1968                          int iWidth = m_pWorkspace->width();                  if (w < frameRect.width())
1969                          if (iWidth < pMdiSubWindow->width())                          w = frameRect.width();
1970                                  iWidth = pMdiSubWindow->width();                  const int h = frameRect.height();
1971                          const int iHeight = pMdiSubWindow->frameGeometry().height();                  pMdiSubWindow->setGeometry(0, y, w, h);
1972                          pMdiSubWindow->setGeometry(0, y, iWidth, iHeight);                  y += h;
                         y += iHeight;  
                 }  
1973          }          }
1974          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1975    
# Line 1927  void MainForm::channelsArrange (void) Line 1980  void MainForm::channelsArrange (void)
1980  // Auto-arrange channel strips.  // Auto-arrange channel strips.
1981  void MainForm::channelsAutoArrange ( bool bOn )  void MainForm::channelsAutoArrange ( bool bOn )
1982  {  {
1983          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1984                  return;                  return;
1985    
1986          // Toggle the auto-arrange flag.          // Toggle the auto-arrange flag.
# Line 2031  void MainForm::helpAbout (void) Line 2084  void MainForm::helpAbout (void)
2084          sText += "</small>";          sText += "</small>";
2085          sText += "</p>\n";          sText += "</p>\n";
2086    
2087          QMessageBox::about(this, tr("About") + " " QSAMPLER_TITLE, sText);          QMessageBox::about(this, tr("About"), sText);
2088  }  }
2089    
2090    
# Line 2044  void MainForm::stabilizeForm (void) Line 2097  void MainForm::stabilizeForm (void)
2097          QString sSessionName = sessionName(m_sFilename);          QString sSessionName = sessionName(m_sFilename);
2098          if (m_iDirtyCount > 0)          if (m_iDirtyCount > 0)
2099                  sSessionName += " *";                  sSessionName += " *";
2100          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(sSessionName);
2101    
2102          // Update the main menu state...          // Update the main menu state...
2103          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
2104          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();
2105          const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          const bool bHasClient = (m_pOptions != nullptr && m_pClient != nullptr);
2106          const bool bHasChannel = (bHasClient && pChannelStrip != NULL);          const bool bHasChannel = (bHasClient && pChannelStrip != nullptr);
2107          const bool bHasChannels = (bHasClient && wlist.count() > 0);          const bool bHasChannels = (bHasClient && wlist.count() > 0);
2108          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
2109          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
2110          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
2111          m_ui.fileSaveAsAction->setEnabled(bHasClient);          m_ui.fileSaveAsAction->setEnabled(bHasClient);
2112          m_ui.fileResetAction->setEnabled(bHasClient);          m_ui.fileResetAction->setEnabled(bHasClient);
2113          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == nullptr);
2114          m_ui.editAddChannelAction->setEnabled(bHasClient);          m_ui.editAddChannelAction->setEnabled(bHasClient);
2115          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);
2116          m_ui.editSetupChannelAction->setEnabled(bHasChannel);          m_ui.editSetupChannelAction->setEnabled(bHasChannel);
# Line 2206  void MainForm::updateAllChannelStrips ( Line 2259  void MainForm::updateAllChannelStrips (
2259    
2260          // Retrieve the current channel list.          // Retrieve the current channel list.
2261          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2262          if (piChannelIDs == NULL) {          if (piChannelIDs == nullptr) {
2263                  if (::lscp_client_get_errno(m_pClient)) {                  if (::lscp_client_get_errno(m_pClient)) {
2264                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
2265                          appendMessagesError(                          appendMessagesError(
# Line 2226  void MainForm::updateAllChannelStrips ( Line 2279  void MainForm::updateAllChannelStrips (
2279                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2280                          const QList<QMdiSubWindow *>& wlist                          const QList<QMdiSubWindow *>& wlist
2281                                  = m_pWorkspace->subWindowList();                                  = m_pWorkspace->subWindowList();
2282                          const int iStripCount = wlist.count();                          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2283                          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                  ChannelStrip *pChannelStrip
2284                                  ChannelStrip *pChannelStrip = NULL;                                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                 if (pMdiSubWindow)  
                                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2285                                  if (pChannelStrip) {                                  if (pChannelStrip) {
2286                                          bool bExists = false;                                          bool bExists = false;
2287                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2288                                                  Channel *pChannel = pChannelStrip->channel();                                                  Channel *pChannel = pChannelStrip->channel();
2289                                                  if (pChannel == NULL)                                                  if (pChannel == nullptr)
2290                                                          break;                                                          break;
2291                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {
2292                                                          // strip exists, don't touch it                                                          // strip exists, don't touch it
# Line 2259  void MainForm::updateAllChannelStrips ( Line 2309  void MainForm::updateAllChannelStrips (
2309  // Update the recent files list and menu.  // Update the recent files list and menu.
2310  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2311  {  {
2312          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2313                  return;                  return;
2314    
2315          // Remove from list if already there (avoid duplicates)          // Remove from list if already there (avoid duplicates)
# Line 2274  void MainForm::updateRecentFiles ( const Line 2324  void MainForm::updateRecentFiles ( const
2324  // Update the recent files list and menu.  // Update the recent files list and menu.
2325  void MainForm::updateRecentFilesMenu (void)  void MainForm::updateRecentFilesMenu (void)
2326  {  {
2327          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2328                  return;                  return;
2329    
2330          // Time to keep the list under limits.          // Time to keep the list under limits.
# Line 2308  void MainForm::updateInstrumentNames (vo Line 2358  void MainForm::updateInstrumentNames (vo
2358                  return;                  return;
2359    
2360          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2361          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2362          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2363                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2364                  if (pChannelStrip)                  if (pChannelStrip)
2365                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
2366          }          }
# Line 2324  void MainForm::updateInstrumentNames (vo Line 2371  void MainForm::updateInstrumentNames (vo
2371  // Force update of the channels display font.  // Force update of the channels display font.
2372  void MainForm::updateDisplayFont (void)  void MainForm::updateDisplayFont (void)
2373  {  {
2374          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2375                  return;                  return;
2376    
2377          // Check if display font is legal.          // Check if display font is legal.
# Line 2343  void MainForm::updateDisplayFont (void) Line 2390  void MainForm::updateDisplayFont (void)
2390                  return;                  return;
2391    
2392          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2393          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2394          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2395                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2396                  if (pChannelStrip)                  if (pChannelStrip)
2397                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2398          }          }
# Line 2366  void MainForm::updateDisplayEffect (void Line 2410  void MainForm::updateDisplayEffect (void
2410                  return;                  return;
2411    
2412          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2413          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2414          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2415                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2416                  if (pChannelStrip)                  if (pChannelStrip)
2417                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2418          }          }
# Line 2382  void MainForm::updateDisplayEffect (void Line 2423  void MainForm::updateDisplayEffect (void
2423  // Force update of the channels maximum volume setting.  // Force update of the channels maximum volume setting.
2424  void MainForm::updateMaxVolume (void)  void MainForm::updateMaxVolume (void)
2425  {  {
2426          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2427                  return;                  return;
2428    
2429  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
# Line 2399  void MainForm::updateMaxVolume (void) Line 2440  void MainForm::updateMaxVolume (void)
2440                  return;                  return;
2441    
2442          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2443          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2444          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2445                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2446                  if (pChannelStrip)                  if (pChannelStrip)
2447                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2448          }          }
# Line 2449  void MainForm::appendMessagesError( cons Line 2487  void MainForm::appendMessagesError( cons
2487          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2488    
2489          if (m_pOptions && m_pOptions->bConfirmError) {          if (m_pOptions && m_pOptions->bConfirmError) {
2490                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Error");                  const QString& sTitle = tr("Error");
2491          #if 0          #if 0
2492                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);
2493          #else          #else
# Line 2472  void MainForm::appendMessagesError( cons Line 2510  void MainForm::appendMessagesError( cons
2510  // This is a special message format, just for client results.  // This is a special message format, just for client results.
2511  void MainForm::appendMessagesClient( const QString& s )  void MainForm::appendMessagesClient( const QString& s )
2512  {  {
2513          if (m_pClient == NULL)          if (m_pClient == nullptr)
2514                  return;                  return;
2515    
2516          appendMessagesColor(s + QString(": %1 (errno=%2)")          appendMessagesColor(s + QString(": %1 (errno=%2)")
# Line 2487  void MainForm::appendMessagesClient( con Line 2525  void MainForm::appendMessagesClient( con
2525  // Force update of the messages font.  // Force update of the messages font.
2526  void MainForm::updateMessagesFont (void)  void MainForm::updateMessagesFont (void)
2527  {  {
2528          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2529                  return;                  return;
2530    
2531          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {
# Line 2501  void MainForm::updateMessagesFont (void) Line 2539  void MainForm::updateMessagesFont (void)
2539  // Update messages window line limit.  // Update messages window line limit.
2540  void MainForm::updateMessagesLimit (void)  void MainForm::updateMessagesLimit (void)
2541  {  {
2542          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2543                  return;                  return;
2544    
2545          if (m_pMessages) {          if (m_pMessages) {
# Line 2516  void MainForm::updateMessagesLimit (void Line 2554  void MainForm::updateMessagesLimit (void
2554  // Enablement of the messages capture feature.  // Enablement of the messages capture feature.
2555  void MainForm::updateMessagesCapture (void)  void MainForm::updateMessagesCapture (void)
2556  {  {
2557          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2558                  return;                  return;
2559    
2560          if (m_pMessages)          if (m_pMessages)
# Line 2530  void MainForm::updateMessagesCapture (vo Line 2568  void MainForm::updateMessagesCapture (vo
2568  // The channel strip creation executive.  // The channel strip creation executive.
2569  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2570  {  {
2571          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == nullptr || pChannel == nullptr)
2572                  return NULL;                  return nullptr;
2573    
2574          // Add a new channel itema...          // Add a new channel itema...
2575          ChannelStrip *pChannelStrip = new ChannelStrip();          ChannelStrip *pChannelStrip = new ChannelStrip();
2576          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
2577                  return NULL;                  return nullptr;
2578    
2579          // Set some initial channel strip options...          // Set some initial channel strip options...
2580          if (m_pOptions) {          if (m_pOptions) {
# Line 2552  ChannelStrip *MainForm::createChannelStr Line 2590  ChannelStrip *MainForm::createChannelStr
2590          }          }
2591    
2592          // Add it to workspace...          // Add it to workspace...
2593          m_pWorkspace->addSubWindow(pChannelStrip,          QMdiSubWindow *pMdiSubWindow
2594                  Qt::SubWindow | Qt::FramelessWindowHint);                  = m_pWorkspace->addSubWindow(pChannelStrip,
2595                            Qt::SubWindow | Qt::FramelessWindowHint);
2596            pMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose);
2597    
2598          // Actual channel strip setup...          // Actual channel strip setup...
2599          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
# Line 2577  void MainForm::destroyChannelStrip ( Cha Line 2617  void MainForm::destroyChannelStrip ( Cha
2617  {  {
2618          QMdiSubWindow *pMdiSubWindow          QMdiSubWindow *pMdiSubWindow
2619                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2620          if (pMdiSubWindow == NULL)          if (pMdiSubWindow == nullptr)
2621                  return;                  return;
2622    
2623          // Just delete the channel strip.          // Just delete the channel strip.
# Line 2596  ChannelStrip *MainForm::activeChannelStr Line 2636  ChannelStrip *MainForm::activeChannelStr
2636          if (pMdiSubWindow)          if (pMdiSubWindow)
2637                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2638          else          else
2639                  return NULL;                  return nullptr;
2640  }  }
2641    
2642    
2643  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2644  ChannelStrip *MainForm::channelStripAt ( int iStrip )  ChannelStrip *MainForm::channelStripAt ( int iStrip )
2645  {  {
2646          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return nullptr;
2647    
2648          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2649                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2650          if (wlist.isEmpty())          if (wlist.isEmpty())
2651                  return NULL;                  return nullptr;
2652    
2653          if (iStrip < 0 || iStrip >= wlist.count())          if (iStrip < 0 || iStrip >= wlist.count())
2654                  return NULL;                  return nullptr;
2655    
2656          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2657          if (pMdiSubWindow)          if (pMdiSubWindow)
2658                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2659          else          else
2660                  return NULL;                  return nullptr;
2661  }  }
2662    
2663    
# Line 2627  ChannelStrip *MainForm::channelStrip ( i Line 2667  ChannelStrip *MainForm::channelStrip ( i
2667          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2668                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2669          if (wlist.isEmpty())          if (wlist.isEmpty())
2670                  return NULL;                  return nullptr;
2671    
2672          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2673          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2674                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2675                  if (pChannelStrip) {                  if (pChannelStrip) {
2676                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2677                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2643  ChannelStrip *MainForm::channelStrip ( i Line 2680  ChannelStrip *MainForm::channelStrip ( i
2680          }          }
2681    
2682          // Not found.          // Not found.
2683          return NULL;          return nullptr;
2684  }  }
2685    
2686    
# Line 2658  void MainForm::channelsMenuAboutToShow ( Line 2695  void MainForm::channelsMenuAboutToShow (
2695                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2696          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2697                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2698                  const int iStripCount = wlist.count();                  int iStrip = 0;
2699                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2700                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip
2701                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2702                          if (pChannelStrip) {                          if (pChannelStrip) {
2703                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2704                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2672  void MainForm::channelsMenuAboutToShow ( Line 2707  void MainForm::channelsMenuAboutToShow (
2707                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);
2708                                  pAction->setData(iStrip);                                  pAction->setData(iStrip);
2709                          }                          }
2710                            ++iStrip;
2711                  }                  }
2712          }          }
2713  }  }
# Line 2682  void MainForm::channelsMenuActivated (vo Line 2718  void MainForm::channelsMenuActivated (vo
2718  {  {
2719          // Retrive channel index from action data...          // Retrive channel index from action data...
2720          QAction *pAction = qobject_cast<QAction *> (sender());          QAction *pAction = qobject_cast<QAction *> (sender());
2721          if (pAction == NULL)          if (pAction == nullptr)
2722                  return;                  return;
2723    
2724          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
# Line 2713  void MainForm::stopSchedule (void) Line 2749  void MainForm::stopSchedule (void)
2749  // Timer slot funtion.  // Timer slot funtion.
2750  void MainForm::timerSlot (void)  void MainForm::timerSlot (void)
2751  {  {
2752          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2753                  return;                  return;
2754    
2755          // Is it the first shot on server start after a few delay?          // Is it the first shot on server start after a few delay?
# Line 2748  void MainForm::timerSlot (void) Line 2784  void MainForm::timerSlot (void)
2784                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2785                                  const QList<QMdiSubWindow *>& wlist                                  const QList<QMdiSubWindow *>& wlist
2786                                          = m_pWorkspace->subWindowList();                                          = m_pWorkspace->subWindowList();
2787                                  const int iStripCount = wlist.count();                                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2788                                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                          ChannelStrip *pChannelStrip
2789                                          ChannelStrip *pChannelStrip = NULL;                                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                         if (pMdiSubWindow)  
                                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2790                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2791                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2792                                  }                                  }
# Line 2772  void MainForm::timerSlot (void) Line 2805  void MainForm::timerSlot (void)
2805  // Start linuxsampler server...  // Start linuxsampler server...
2806  void MainForm::startServer (void)  void MainForm::startServer (void)
2807  {  {
2808          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2809                  return;                  return;
2810    
2811          // Aren't already a client, are we?          // Aren't already a client, are we?
# Line 2782  void MainForm::startServer (void) Line 2815  void MainForm::startServer (void)
2815          // Is the server process instance still here?          // Is the server process instance still here?
2816          if (m_pServer) {          if (m_pServer) {
2817                  if (QMessageBox::warning(this,                  if (QMessageBox::warning(this,
2818                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
2819                          tr("Could not start the LinuxSampler server.\n\n"                          tr("Could not start the LinuxSampler server.\n\n"
2820                          "Maybe it is already started."),                          "Maybe it is already started."),
2821                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
# Line 2852  void MainForm::stopServer ( bool bIntera Line 2885  void MainForm::stopServer ( bool bIntera
2885    
2886          if (m_pServer && bInteractive) {          if (m_pServer && bInteractive) {
2887                  if (QMessageBox::question(this,                  if (QMessageBox::question(this,
2888                          QSAMPLER_TITLE ": " + tr("The backend's fate ..."),                          tr("The backend's fate ..."),
2889                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"
2890                          "running in the background. The sampler would continue to work\n"                          "running in the background. The sampler would continue to work\n"
2891                          "according to your current sampler session and you could alter the\n"                          "according to your current sampler session and you could alter the\n"
# Line 2864  void MainForm::stopServer ( bool bIntera Line 2897  void MainForm::stopServer ( bool bIntera
2897                  }                  }
2898          }          }
2899    
2900            bool bGraceWait = true;
2901    
2902          // And try to stop server.          // And try to stop server.
2903          if (m_pServer && m_bForceServerStop) {          if (m_pServer && m_bForceServerStop) {
2904                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2905                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2906                  #if defined(_WIN32)                  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
2907                          // Try harder...                          // Try harder...
2908                          m_pServer->kill();                          m_pServer->kill();
2909                  #else                  #else
2910                          // Try softly...                          // Try softly...
2911                          m_pServer->terminate();                          m_pServer->terminate();
2912                            bool bFinished = m_pServer->waitForFinished(QSAMPLER_TIMER_MSECS * 1000);
2913                            if (bFinished) bGraceWait = false;
2914                  #endif                  #endif
2915                  }                  }
2916          }       // Do final processing anyway.          }       // Do final processing anyway.
2917          else processServerExit();          else processServerExit();
2918    
2919          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2920          QTime t;          if (bGraceWait) {
2921          t.start();                  QTime t;
2922          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  t.start();
2923                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2924                            QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2925            }
2926  }  }
2927    
2928    
# Line 2921  void MainForm::processServerExit (void) Line 2960  void MainForm::processServerExit (void)
2960                          tr("Server was stopped with exit status %1.")                          tr("Server was stopped with exit status %1.")
2961                          .arg(m_pServer->exitStatus()));                          .arg(m_pServer->exitStatus()));
2962                  delete m_pServer;                  delete m_pServer;
2963                  m_pServer = NULL;                  m_pServer = nullptr;
2964          }          }
2965    
2966          // Again, make status visible stable.          // Again, make status visible stable.
# Line 2937  lscp_status_t qsampler_client_callback ( Line 2976  lscp_status_t qsampler_client_callback (
2976          lscp_event_t event, const char *pchData, int cchData, void *pvData )          lscp_event_t event, const char *pchData, int cchData, void *pvData )
2977  {  {
2978          MainForm* pMainForm = (MainForm *) pvData;          MainForm* pMainForm = (MainForm *) pvData;
2979          if (pMainForm == NULL)          if (pMainForm == nullptr)
2980                  return LSCP_FAILED;                  return LSCP_FAILED;
2981    
2982          // ATTN: DO NOT EVER call any GUI code here,          // ATTN: DO NOT EVER call any GUI code here,
# Line 2954  lscp_status_t qsampler_client_callback ( Line 2993  lscp_status_t qsampler_client_callback (
2993  bool MainForm::startClient (void)  bool MainForm::startClient (void)
2994  {  {
2995          // Have it a setup?          // Have it a setup?
2996          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2997                  return false;                  return false;
2998    
2999          // Aren't we already started, are we?          // Aren't we already started, are we?
# Line 2968  bool MainForm::startClient (void) Line 3007  bool MainForm::startClient (void)
3007          m_pClient = ::lscp_client_create(          m_pClient = ::lscp_client_create(
3008                  m_pOptions->sServerHost.toUtf8().constData(),                  m_pOptions->sServerHost.toUtf8().constData(),
3009                  m_pOptions->iServerPort, qsampler_client_callback, this);                  m_pOptions->iServerPort, qsampler_client_callback, this);
3010          if (m_pClient == NULL) {          if (m_pClient == nullptr) {
3011                  // Is this the first try?                  // Is this the first try?
3012                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3013                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
# Line 3038  bool MainForm::startClient (void) Line 3077  bool MainForm::startClient (void)
3077          if (!m_pOptions->sSessionFile.isEmpty()) {          if (!m_pOptions->sSessionFile.isEmpty()) {
3078                  // Just load the prabably startup session...                  // Just load the prabably startup session...
3079                  if (loadSessionFile(m_pOptions->sSessionFile)) {                  if (loadSessionFile(m_pOptions->sSessionFile)) {
3080                          m_pOptions->sSessionFile = QString::null;                          m_pOptions->sSessionFile = QString();
3081                          return true;                          return true;
3082                  }                  }
3083          }          }
# Line 3054  bool MainForm::startClient (void) Line 3093  bool MainForm::startClient (void)
3093  // Stop client...  // Stop client...
3094  void MainForm::stopClient (void)  void MainForm::stopClient (void)
3095  {  {
3096          if (m_pClient == NULL)          if (m_pClient == nullptr)
3097                  return;                  return;
3098    
3099          // Log prepare here.          // Log prepare here.
# Line 3086  void MainForm::stopClient (void) Line 3125  void MainForm::stopClient (void)
3125          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
3126          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
3127          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
3128          m_pClient = NULL;          m_pClient = nullptr;
3129    
3130          // Hard-notify instrumnet and device configuration forms,          // Hard-notify instrumnet and device configuration forms,
3131          // if visible, that we're running out...          // if visible, that we're running out...
# Line 3106  void MainForm::stopClient (void) Line 3145  void MainForm::stopClient (void)
3145  // Channel strip activation/selection.  // Channel strip activation/selection.
3146  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3147  {  {
3148          ChannelStrip *pChannelStrip = NULL;          ChannelStrip *pChannelStrip = nullptr;
3149          if (pMdiSubWindow)          if (pMdiSubWindow)
3150                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3151          if (pChannelStrip)          if (pChannelStrip)

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

  ViewVC Help
Powered by ViewVC