GstBuffer *QGstXvImageBufferPool::takeBuffer( const QVideoSurfaceFormat &format, GstCaps *caps) { m_poolMutex.lock(); m_caps = caps; if (format != m_format) { doClear(); m_format = format; } if (m_pool.isEmpty()) { //qDebug() << "QGstXvImageBufferPool::takeBuffer: no buffer available, allocate the new one" << QThread::currentThreadId() << m_threadId; if (QThread::currentThreadId() == m_threadId) { doAlloc(); } else { QMetaObject::invokeMethod(this, "queuedAlloc", Qt::QueuedConnection); m_allocWaitCondition.wait(&m_poolMutex, 300); } } QGstXvImageBuffer *res = 0; if (!m_pool.isEmpty()) { res = m_pool.takeLast(); } m_poolMutex.unlock(); return GST_BUFFER(res); }
void GoaliePen::decide() { Vector Me; vector <int> opps = pWorldData->mr_found_opponents(); Point ballPos = pWorldData->basedCenter(pWorldData->ball()); Point closestOppToBalll; if(opps.size() != 0) pWorldData->basedCenter(pWorldData->opponent(pWorldData->getNearstOppToPoint(ballPos))); Point me; me.x = Me.getX(); me.y = Me.getY(); if(pBasicPlayer->can_kick()) doClear(); else { if(me.getDistance(closestOppToBalll) > ballPos.getDistance(closestOppToBalll) && opps.size() != 0) doBlock(); else doGo(); } }
TerminalLineEdit::TerminalLineEdit(QWidget *parent) : QLineEdit(parent) { logMessage("TerminalLineEdit::TerminalLineEdit()"); m_model = dynamic_cast<QStringListModel *>(Util::completer()->model()); m_index = -1; connect(this, SIGNAL(returnPressed()), this, SLOT(doClear())); }
bool BaseFile::clear() { if(shouldSave()) if(!confirmDiscardChanges()) return false; doClear(); return true; }
const RETURN_VALUE NetworkQueueTS::clear() { RETURN_VALUE ret; EnterCriticalSection(&this->m_critSec); { ret = doClear(); } LeaveCriticalSection(&this->m_critSec); return ret; }
void PartsBinView::setPaletteModel(PaletteModel * model, bool clear) { if (clear) { doClear(); } if (model->root() == NULL) return; setItemAux(model->root()); setItem(model->root()); }
MainWindow::MainWindow(QApplication* app) { QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); this->setWindowTitle("kmeans"); // create status bar m_framesPerSec = new QLabel("nA"); m_framesPerSec->setMinimumSize(m_framesPerSec->sizeHint()); m_framesPerSec->setAlignment(Qt::AlignLeft); m_framesPerSec->setToolTip("Current frames per second not yet initialized."); statusBar()->addWidget(m_framesPerSec); m_viewport = new Viewport(this); m_viewport->show(); m_toolBox = new ToolBox(); QSplitter* splitter = new QSplitter(Qt::Horizontal); splitter->insertWidget(0, m_toolBox); splitter->insertWidget(1, m_viewport); QList<int> sizes; sizes.append(200); sizes.append(1300); splitter->setSizes(sizes); splitter->setStretchFactor(0, 1); splitter->setStretchFactor(1, 1); splitter->setChildrenCollapsible(false); setCentralWidget(splitter); connect(m_viewport, SIGNAL(framesPerSecondChanged(int)), this, SLOT(updateFramesPerSecond(int))); connect(m_toolBox, SIGNAL(setSeedingAlgorithm(SeedingAlgorithm)), m_viewport, SLOT(setSeedingAlgorithm(SeedingAlgorithm))); connect(m_toolBox->m_doClusterButton, SIGNAL(clicked()), m_viewport, SLOT(doCluster())); connect(m_toolBox->m_findKButton, SIGNAL(clicked()), m_viewport, SLOT(findK())); connect(m_toolBox->m_kBox, SIGNAL(valueChanged(int)), m_viewport, SLOT(setK(int))); connect(m_toolBox->m_iterationsBox, SIGNAL(valueChanged(int)), m_viewport, SLOT(setIterations(int))); connect(m_toolBox->m_runBox, SIGNAL(valueChanged(int)), m_viewport, SLOT(setRuns(int))); connect(m_toolBox->m_clearButton, SIGNAL(clicked()), m_viewport, SLOT(doClear())); connect(m_toolBox->m_clearSeedButton, SIGNAL(clicked()), m_viewport, SLOT(doClearSeed())); show(); this->adjustSize(); m_viewport->updateGL(); m_viewport->m_timer->start(); }
void testRandom(size_t numSteps = 10000) { describePlatform(); auto target = folly::make_unique<T>(); std::vector<bool> valid; for (size_t step = 0; step < numSteps; ++step) { auto pct = folly::Random::rand32(100); auto v = folly::Random::rand32(uint32_t{3} << folly::Random::rand32(14)); if (pct < 5) { doClear(*target, valid); } else if (pct < 30) { T copy; folly::resizeWithoutInitialization(copy, target->size()); for (size_t i = 0; i < copy.size(); ++i) { if (valid[i]) { copy[i] = target->at(i); } } if (pct < 10) { std::swap(copy, *target); } else if (pct < 15) { *target = std::move(copy); } else if (pct < 20) { *target = copy; } else if (pct < 25) { target = folly::make_unique<T>(std::move(copy)); } else { target = folly::make_unique<T>(copy); } } else if (pct < 35) { target->reserve(v); } else if (pct < 40) { target->shrink_to_fit(); } else if (pct < 45) { doResize(*target, valid, v); } else if (pct < 50) { doInsert(*target, valid, v % (target->size() + 1)); } else if (pct < 55) { if (!target->empty()) { doErase(*target, valid, v % target->size()); } } else if (pct < 60) { doPushBack(*target, valid); } else if (pct < 65) { target = folly::make_unique<T>(); valid.clear(); } else if (pct < 80) { auto v2 = folly::Random::rand32(uint32_t{3} << folly::Random::rand32(14)); doOverwrite(*target, valid, std::min(v, v2), std::max(v, v2)); } else { doResizeWithoutInit(*target, valid, v); } // don't check every time in implementation does lazy work if (folly::Random::rand32(100) < 50) { check(*target); } } }
void QGstXvImageBufferPool::clear() { QMutexLocker lock(&m_poolMutex); doClear(); }
const RETURN_VALUE NetworkQueue::clear() { return doClear(); }
void ChatDlg::doSend() { if (!chatEdit()->isEnabled()) { return; } if (chatEdit()->text().isEmpty()) { return; } if (chatEdit()->text() == "/clear") { chatEdit()->clear(); doClear(); return; } if (!account()->loggedIn()) { return; } if (warnSend_) { warnSend_ = false; int n = QMessageBox::information(this, tr("Warning"), tr( "<p>Encryption was recently disabled by the remote contact. " "Are you sure you want to send this message without encryption?</p>" ), tr("&Yes"), tr("&No")); if (n != 0) { return; } } Message m(jid()); m.setType("chat"); m.setBody(chatEdit()->text()); m.setTimeStamp(QDateTime::currentDateTime()); if (isEncryptionEnabled()) { m.setWasEncrypted(true); } m_ = m; // Request events if (PsiOptions::instance()->getOption("options.messages.send-composing-events").toBool()) { // Only request more events when really necessary if (sendComposingEvents_) { m.addEvent(ComposingEvent); } m.setChatState(XMPP::StateActive); } // Update current state setChatState(XMPP::StateActive); if (isEncryptionEnabled()) { chatEdit()->setEnabled(false); transid_ = account()->sendMessageEncrypted(m); if (transid_ == -1) { chatEdit()->setEnabled(true); chatEdit()->setFocus(); return; } } else { aSend(m); doneSend(); } chatEdit()->setFocus(); }
void tryClear(){ if (!m_isInited) return; doClear(); m_isInited=false; }
YaChatViewModel::~YaChatViewModel() { doClear(); }