/[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 1558 by capela, Thu Dec 6 09:35:33 2007 UTC revision 1559 by capela, Thu Dec 6 14:23:39 2007 UTC
# Line 2414  void MainForm::startServer (void) Line 2414  void MainForm::startServer (void)
2414    
2415          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2416  //      if (m_pOptions->bStdoutCapture) {  //      if (m_pOptions->bStdoutCapture) {
2417                  //m_pServer->setProcessChannelMode(  #if QT_VERSION >= 0x040200
2418                  //      QProcess::StandardOutput);                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
2419    #endif
2420                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2421                          SIGNAL(readyReadStandardOutput()),                          SIGNAL(readyReadStandardOutput()),
2422                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
# Line 2426  void MainForm::startServer (void) Line 2427  void MainForm::startServer (void)
2427    
2428          // The unforgiveable signal communication...          // The unforgiveable signal communication...
2429          QObject::connect(m_pServer,          QObject::connect(m_pServer,
2430                  SIGNAL(finished(int,QProcess::ExitStatus)),                  SIGNAL(finished(int, QProcess::ExitStatus)),
2431                  SLOT(processServerExit()));                  SLOT(processServerExit()));
2432    
2433          // Build process arguments...          // Build process arguments...
# Line 2465  void MainForm::stopServer (void) Line 2466  void MainForm::stopServer (void)
2466          // And try to stop server.          // And try to stop server.
2467          if (m_pServer) {          if (m_pServer) {
2468                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2469                  if (m_pServer->state() == QProcess::Running)                  if (m_pServer->state() == QProcess::Running) {
2470    #if defined(WIN32)
2471                            // Try harder...
2472                            m_pServer->kill();
2473    #else
2474                            // Try softly...
2475                          m_pServer->terminate();                          m_pServer->terminate();
2476          }  #endif
2477                    }
2478            }       // Do final processing anyway.
2479            else processServerExit();
2480    
2481          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2482          QTime t;          QTime t;
2483          t.start();          t.start();
2484          while (t.elapsed() < QSAMPLER_TIMER_MSECS)          while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2485                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
   
         // Do final processing anyway.  
         processServerExit();  
2486  }  }
2487    
2488    
# Line 2499  void MainForm::processServerExit (void) Line 2505  void MainForm::processServerExit (void)
2505                  m_pMessages->flushStdoutBuffer();                  m_pMessages->flushStdoutBuffer();
2506    
2507          if (m_pServer) {          if (m_pServer) {
2508                    if (m_pServer->state() != QProcess::NotRunning) {
2509                            appendMessages(tr("Server is being forced..."));
2510                            // Force final server shutdown...
2511                            m_pServer->kill();
2512                            // Give it some time to terminate gracefully and stabilize...
2513                            QTime t;
2514                            t.start();
2515                            while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2516                                    QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2517                    }
2518                  // Force final server shutdown...                  // Force final server shutdown...
2519                  appendMessages(                  appendMessages(
2520                          tr("Server was stopped with exit status %1.")                          tr("Server was stopped with exit status %1.")
2521                          .arg(m_pServer->exitStatus()));                          .arg(m_pServer->exitStatus()));
                 m_pServer->terminate();  
                 if (!m_pServer->waitForFinished(2000))  
                         m_pServer->kill();  
                 // Destroy it.  
2522                  delete m_pServer;                  delete m_pServer;
2523                  m_pServer = NULL;                  m_pServer = NULL;
2524          }          }

Legend:
Removed from v.1558  
changed lines
  Added in v.1559

  ViewVC Help
Powered by ViewVC