Esempio n. 1
0
File: Server.C Progetto: Tyf0n/IQmol
void Server::queryFinished()
{
   ServerTask::Query* task = qobject_cast<ServerTask::Query*>(sender());
   if (!task) return;

   Process* process(task->process());
   Process::Status oldStatus(process->status());
   Process::Status newStatus(task->newStatus());
   task->deleteLater();

   // Check for any error and bail cos, really, we don't know what's going on
   QString msg(task->errorMessage());
   if (!msg.isEmpty()) {
      process->setComment(msg);
      process->setStatus(Process::Unknown);
      return;
   }

   if (oldStatus == Process::Queued    || 
       oldStatus == Process::Running   || 
       oldStatus == Process::Suspended ||
       oldStatus == Process::Unknown) {

      if (newStatus == Process::Unknown) {
         ServerTask::Base* task(cleanUp(process));
         if (task) {
            connect(task, SIGNAL(finished()), this, SLOT(cleanUpFinished()));
            task->start();
         }
         removeFromWatchList(process);
         return;
      }else if (newStatus == Process::Queued    || 
                newStatus == Process::Running   || 
                newStatus == Process::Suspended) {
         process->setStatus(newStatus);
      }else {
         process->setStatus(newStatus);
         removeFromWatchList(process);
         QLOG_WARN() << "Inactive process found in Server::queryFinished";
      }
      
   }else {
      removeFromWatchList(process);
   }
}
Esempio n. 2
0
void Server::queryFinished()
{
    ServerTask::Query* task = qobject_cast<ServerTask::Query*>(sender());
    if (!task) return;

    Process* process(task->process());
    Process::Status oldStatus(process->status());
    Process::Status newStatus(task->newStatus());
    task->deleteLater();

    if (oldStatus == Process::Queued    ||
            oldStatus == Process::Running   ||
            oldStatus == Process::Suspended ||
            oldStatus == Process::Unknown) {

        if (newStatus == Process::Unknown) {
            ServerTask::Base* task(cleanUp(process));
            if (task) {
                connect(task, SIGNAL(finished()), this, SLOT(cleanUpFinished()));
                task->start();
            }
            removeFromWatchList(process);
            return;
        } else if (newStatus == Process::Queued    ||
                   newStatus == Process::Running   ||
                   newStatus == Process::Suspended) {
            process->setStatus(newStatus);
        } else {
            process->setStatus(newStatus);
            removeFromWatchList(process);
            QLOG_WARN() << "Inactive process found in Server::queryFinished";
        }

    } else {
        removeFromWatchList(process);
    }
}