void CheckUpdatesWorker::updatesChecked(bool hasUpdates) { // if has updates, then display the update center if (hasUpdates) { //this->setVisible(false); // result checker int result = QDialog::Accepted; // check if we are running windwos vista if (isWindowsVista() && !programOptions->getVistaUpdatesMessage()) { WindowsVistaDetectedImpl windowsVistaDetectedForm(parentForm); result = windowsVistaDetectedForm.exec(); // update the option "don't display this message" programOptions->setVistaUpdatesMessage(windowsVistaDetectedForm.chbDontDisplay->isChecked()); } // open update center (this condition works only on windows vista) if (result == QDialog::Accepted) { emit beforeDisplayUpdateCenter(); // dispaly UpdateCenterImpl updateCenterForm(updates, programOptions->getInstallAutomaticallyUpdates(), parentForm); result = updateCenterForm.exec(); } // wait until "thread end" waitThread(); // updates downloaded??? yes? then install them if (result == QDialog::Accepted) { updates->installUpdates(); QApplication::closeAllWindows(); } else // update center has been cancelled { closedByButton = true; //done(QDialog::Rejected); emit finished(false, closedByButton); } } else { // wait thread end waitThread(); // display no updates message (only if is an user request) if (isUser) native_alert(parentForm, QMessageBox::Information, tr("Updates"), tr("You are using the most recent version of this program."), tr("Ok")); // set as closed by button closedByButton = true; // close emit finished(false, closedByButton); } }
void sleep(int ticks) { if (getCurrentThread() == NULL) { // not ready to wait! uint64_t then = getUptime() + (uint64_t)ticks; while (getUptime() < then); } else { uint64_t then = getUptime() + (uint64_t)ticks; uint64_t nanoThen = then * (uint64_t)1000000; cli(); lockSched(); TimedEvent ev; timedPost(&ev, nanoThen); while (getNanotime() <= nanoThen) { waitThread(getCurrentThread()); unlockSched(); kyield(); cli(); lockSched(); }; timedCancel(&ev); unlockSched(); sti(); }; };
void CheckUpdatesWorker::updatesCancelled() { caption->setText(tr("Cancelling... please wait...")); waitThread(); closedByButton = true; //done(QDialog::Rejected); emit finished(false, closedByButton); }
SearchVideos::~SearchVideos() { disconnect(); // wait while the thread is running destroying = true; this->quit(); waitThread(); // destroy all delete searchResults; delete imageCatcher; }
void CheckUpdatesWorker::updateMessage(QString version, QString url) { // wait thread end waitThread(); // display special updates message native_alert(parentForm, QMessageBox::Information, tr("Update Center"), tr("Please, download the new version of <b>xVideoServiceThief (%1)</b> from <a href='%2'>here.</a>").arg(version).arg(url), tr("Ok")); // set as closed by button closedByButton = true; // close emit finished(false, closedByButton); }
// A file copy thread int FileTransferServer::addCpThread(const std::string& srcUser, const std::string& srcMachineName, const std::string& srcUserKey, const std::string& destUser, const std::string& destMachineName, const FMS_Data::CpFileOptions& options) { mtransferType=File::copy; addTransferThread(srcUser,srcMachineName,srcUserKey, destUser, destMachineName, options); waitThread(); std::string errorMsg(getErrorFromDatabase(mfileTransfer.getTransferId())); if (false == errorMsg.empty()) { throw FMSVishnuException (ERRCODE_RUNTIME_ERROR,errorMsg); } return 0; }
void GarminFilebasedDevice::writeGpxFile() { lockVariables(); string xml = this->xmlToWrite; string filename = this->filenameToWrite; string systemCmd = this->storageCmd; this->threadState = 1; // Working unlockVariables(); struct stat stFileInfo; int intStat; // Attempt to get the file attributes intStat = stat(filename.c_str(),&stFileInfo); if(intStat == 0) { // File exists - we need to ask the user to overwrite lockVariables(); this->waitingMessage = new MessageBox(Question, "File "+filename+" exists. Overwrite?", BUTTON_YES | BUTTON_NO , BUTTON_NO, this); this->threadState = 2; unlockVariables(); waitThread(); // Sleep until thread gets signal (user answered) bool doOverwrite = true; lockVariables(); if (this->overwriteFile != 1) { this->threadState = 3; this->transferSuccessful = false; doOverwrite = false; } unlockVariables(); if (!doOverwrite) { Log::dbg("Thread aborted"); return; } } ofstream file; file.open (filename.c_str()); file << xml; file.close(); // Execute extern command if wanted if (systemCmd.length() > 0) { string placeholder = "%1"; int pos=systemCmd.find( placeholder ); if (pos >=0) { systemCmd.replace(systemCmd.find(placeholder),placeholder.length(),filename); } pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); Log::dbg("Thread before executing user command: "+systemCmd); int ret = system(systemCmd.c_str()); pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); if (ret != 0) { lockVariables(); this->waitingMessage = new MessageBox(Question, "Error executing command: "+systemCmd, BUTTON_OK , BUTTON_OK, NULL); this->threadState = 2; unlockVariables(); sleep(1); // give application time to fetch messagebox lockVariables(); this->threadState = 3; unlockVariables(); Log::err("Executing user command failed: "+systemCmd); return; } } lockVariables(); this->threadState = 3; // Finished this->transferSuccessful = true; // Successfull; unlockVariables(); }
// TODO: this code sucks, too much memory copying, // converting to unnecessary intermediate forms // Thread method which gets automatically started as soon as a slot is // connected int DtkShmMove::processData() { SPEW(); setState(NODE_RUNNING); assert(translationOutSlot_); assert(rotationOutSlot_); float loc[6]; float oldLoc[6] = { NAN, NAN, NAN, NAN, NAN, NAN }; Vec3f translation; Rotation rotation; dtkMatrix mat; dtkSharedMem* shm = new dtkSharedMem(sizeof(loc), "head"); assert(shm); if(!shm) return 1; // fail // TODO: We should be waiting at the sharedMemory read call and // not here. That would give much better performance in so many // ways. Problem is, we have no easy way to interrupt the blocking // shm->blockingRead(loc) call at quiting time. while(waitThread(10)) { if(shm->read(loc)) // not blocking here like a good thread should not // if(shm->blockingRead(loc)) // blocking here like a good thread should // the above call should have spewed. return -1; // fail // TODO: convert units and tranform // TODO: Just moving viewpoint position for now if(IsSameOrSetFloat6(oldLoc, loc)) continue; // TODO: add a x,y,z, scaling. // fill in InstantReality translation translation.set(loc[0], loc[2], -loc[1]); // send out the InstantReality translation translationOutSlot_->push(translation); mat.identity(); // Unless you wrote the DTK matrix code yesterday forget about // understanding this code without running the example in // InstantPlayer. // Through trial and error we found that we need to // set up these three calls in this order. // You cannot do this in one rotateHPR() call. mat.rotateHPR(-loc[5], 0, 0);// Diverse Heading is minus InstantReality Roll mat.rotateHPR(0, loc[4], 0); // Diverse Pitch is InstantReality Pitch mat.rotateHPR(0, 0, loc[3]); // Diverse Roll is InstantReality Heading // fill in InstantReality rotations in quaternions. mat.quat(&rotation[0], &rotation[1], &rotation[2], &rotation[3]); // send out the InstantReality rotation rotationOutSlot_->push(rotation); } delete shm; // Thread finished setState(NODE_SLEEPING); SPEW(); return 0; }