本文整理汇总了C++中QThread类的典型用法代码示例。如果您正苦于以下问题:C++ QThread类的具体用法?C++ QThread怎么用?C++ QThread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CNetRender::ProcessData(QTcpSocket *socket, sMessage *inMsg)
{
// beware: payload points to char, first cast to target type pointer, then dereference
// *(qint32*)msg->payload
//------------------------- CLIENT ------------------------
if(IsClient())
{
switch ((netCommand)inMsg->command)
{
case netRender_VERSION:
{
sMessage outMsg;
if(*(qint32*)inMsg->payload.data() == version)
{
WriteLog("NetRender - version matches (" + QString::number(version) + "), connection established");
if(systemData.noGui)
{
QTextStream out(stdout);
out << "NetRender - version matches (" + QString::number(version) + "), connection established\n";
}
// server version matches, send worker count
outMsg.command = netRender_WORKER;
QDataStream stream(&outMsg.payload, QIODevice::WriteOnly);
stream << workerCount;
QString machineName = QHostInfo::localHostName();
stream << (qint32)machineName.toUtf8().size();
stream.writeRawData(machineName.toUtf8().data(), machineName.toUtf8().size());
status = netRender_READY;
emit NewStatusClient();
}
else
{
qWarning() << "CNetRender - version mismatch! client version: " << version << ", server: " << *(qint32*)inMsg->payload.data();
outMsg.command = netRender_BAD;
}
SendData(clientSocket, outMsg);
break;
}
case netRender_STOP:
{
status = netRender_READY;
gMainInterface->stopRequest = true;
emit NotifyStatus();
WriteLog("CNetRender - STOP");
break;
}
case netRender_STATUS:
{
emit NotifyStatus();
break;
}
case netRender_JOB:
{
if (inMsg->id == actualId)
{
WriteLog("NetRender - received new job");
QDataStream stream(&inMsg->payload, QIODevice::ReadOnly);
QByteArray buffer;
qint32 size;
status = netRender_WORKING;
emit NotifyStatus();
// read settings
stream >> size;
buffer.resize(size);
stream.readRawData(buffer.data(), size);
settingsText = QString::fromUtf8(buffer.data(), buffer.size());
// read textures
for (int i = 0; i < textures.textureList.size(); i++)
{
stream >> size;
if (size > 0)
{
buffer.resize(size);
stream.readRawData(buffer.data(), size);
textures.textureList[i]->FromQByteArray(buffer);
}
}
cSettings parSettings(cSettings::formatCondensedText);
parSettings.BeQuiet(true);
parSettings.LoadFromString(settingsText);
parSettings.Decode(gPar, gParFractal);
if(!systemData.noGui)
{
gMainInterface->SynchronizeInterface(gPar, gParFractal, cInterface::write);
gMainInterface->StartRender(true);
}
else
{
//in noGui mode it must be started as separate thread to be able to process event loop
gMainInterface->headless = new cHeadless;
QThread *thread = new QThread; //deleted by deleteLater()
gMainInterface->headless->moveToThread(thread);
//.........这里部分代码省略.........
示例2: qDebug
//.........这里部分代码省略.........
}
updateLoginMessage();
maxGameInactivityTime = settingsCache->value("game/max_game_inactivity_time", 120).toInt();
maxPlayerInactivityTime = settingsCache->value("game/max_player_inactivity_time", 15).toInt();
maxUsersPerAddress = settingsCache->value("security/max_users_per_address", 4).toInt();
messageCountingInterval = settingsCache->value("security/message_counting_interval", 10).toInt();
maxMessageCountPerInterval = settingsCache->value("security/max_message_count_per_interval", 15).toInt();
maxMessageSizePerInterval = settingsCache->value("security/max_message_size_per_interval", 1000).toInt();
maxGamesPerUser = settingsCache->value("security/max_games_per_user", 5).toInt();
commandCountingInterval = settingsCache->value("game/command_counting_interval", 10).toInt();
maxCommandCountPerInterval = settingsCache->value("game/max_command_count_per_interval", 20).toInt();
try { if (settingsCache->value("servernetwork/active", 0).toInt()) {
qDebug() << "Connecting to ISL network.";
const QString certFileName = settingsCache->value("servernetwork/ssl_cert").toString();
const QString keyFileName = settingsCache->value("servernetwork/ssl_key").toString();
qDebug() << "Loading certificate...";
QFile certFile(certFileName);
if (!certFile.open(QIODevice::ReadOnly))
throw QString("Error opening certificate file: %1").arg(certFileName);
QSslCertificate cert(&certFile);
#if QT_VERSION < 0x050000
if (!cert.isValid())
throw(QString("Invalid certificate."));
#else
const QDateTime currentTime = QDateTime::currentDateTime();
if(currentTime < cert.effectiveDate() ||
currentTime > cert.expiryDate() ||
cert.isBlacklisted())
throw(QString("Invalid certificate."));
#endif
qDebug() << "Loading private key...";
QFile keyFile(keyFileName);
if (!keyFile.open(QIODevice::ReadOnly))
throw QString("Error opening private key file: %1").arg(keyFileName);
QSslKey key(&keyFile, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
if (key.isNull())
throw QString("Invalid private key.");
QMutableListIterator<ServerProperties> serverIterator(serverList);
while (serverIterator.hasNext()) {
const ServerProperties &prop = serverIterator.next();
if (prop.cert == cert) {
serverIterator.remove();
continue;
}
QThread *thread = new QThread;
thread->setObjectName("isl_" + QString::number(prop.id));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
IslInterface *interface = new IslInterface(prop.id, prop.hostname, prop.address.toString(), prop.controlPort, prop.cert, cert, key, this);
interface->moveToThread(thread);
connect(interface, SIGNAL(destroyed()), thread, SLOT(quit()));
thread->start();
QMetaObject::invokeMethod(interface, "initClient", Qt::BlockingQueuedConnection);
}
const int networkPort = settingsCache->value("servernetwork/port", 14747).toInt();
qDebug() << "Starting ISL server on port" << networkPort;
islServer = new Servatrice_IslServer(this, cert, key, this);
if (islServer->listen(QHostAddress::Any, networkPort))
qDebug() << "ISL server listening.";
else
throw QString("islServer->listen()");
} } catch (QString error) {
qDebug() << "ERROR --" << error;
return false;
}
pingClock = new QTimer(this);
connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout()));
pingClock->start(1000);
int statusUpdateTime = settingsCache->value("server/statusupdate", 15000).toInt();
statusUpdateClock = new QTimer(this);
connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate()));
if (statusUpdateTime != 0) {
qDebug() << "Starting status update clock, interval " << statusUpdateTime << " ms";
statusUpdateClock->start(statusUpdateTime);
}
const int numberPools = settingsCache->value("server/number_pools", 1).toInt();
gameServer = new Servatrice_GameServer(this, numberPools, servatriceDatabaseInterface->getDatabase(), this);
gameServer->setMaxPendingConnections(1000);
const int gamePort = settingsCache->value("server/port", 4747).toInt();
qDebug() << "Starting server on port" << gamePort;
if (gameServer->listen(QHostAddress::Any, gamePort))
qDebug() << "Server listening.";
else {
qDebug() << "gameServer->listen(): Error:" << gameServer->errorString();
return false;
}
return true;
}
示例3: QAdoptedThread
QThread *QAdoptedThread::createThreadForAdoption()
{
QThread *t = new QAdoptedThread(0);
t->moveToThread(t);
return t;
}
示例4: main
int main(int argc, char *argv[])
{
// enable multithreaded opengl on linux
#ifdef __GNUC__
XInitThreads();
#endif
using namespace dtEntityEditor;
// start up Qt
MyQApplication qtapp(argc, argv);
// for QSettings
QCoreApplication::setOrganizationName("dtEntity");
QCoreApplication::setOrganizationDomain("dtEntity");
QCoreApplication::setApplicationName("dtEntity Editor");
// let OpenSceneGraph window be a Qt widget
dtEntityQtWidgets::QtGuiWindowSystemWrapper::EnableQtGUIWrapper();
// register some used classes as Qt meta types so that they can be
// used in signal slot connections
qRegisterMetaType<dtEntity::EntityId>("dtEntity::EntityId");
qRegisterMetaType<dtEntity::ComponentType>("dtEntity::ComponentType");
qRegisterMetaType<dtEntity::StringId>("dtEntity::StringId");
qRegisterMetaType<osg::Vec2>("osg::Vec2");
qRegisterMetaType<osg::Vec3>("osg::Vec3");
qRegisterMetaType<osg::Vec4>("osg::Vec4");
qRegisterMetaType<osg::Timer_t>("osg::Timer_t");
qRegisterMetaType<dtEntity::GroupProperty>("dtEntity::GroupProperty");
qRegisterMetaType<dtEntityQtWidgets::OSGGraphicsWindowQt*>("dtEntityQtWidgets::OSGGraphicsWindowQt*");
bool singleThread = false;
QString pluginPath = "plugins";
QString scene = "";
for(int curArg = 1; curArg < argc; ++curArg)
{
std::string curArgv = argv[curArg];
if (curArgv.empty())
{
continue;
}
else if(curArgv == "--singleThread")
{
singleThread = true;
}
else if(curArgv == "--scene")
{
++curArg;
if (curArg < argc)
{
scene = argv[curArg];
}
}
else if(curArgv == "--pluginPath")
{
++curArg;
if (curArg < argc)
{
pluginPath = argv[curArg];
}
}
}
osg::ref_ptr<EditorApplication> application = new EditorApplication(argc, argv);
application->SetAdditionalPluginPath(pluginPath);
QThread* viewerThread;
if(!singleThread)
{
// start dtEntity in a background thread. All communications between
// Qt and dtEntity go over signal slot connections.
viewerThread = new QThread();
application->moveToThread(viewerThread);
}
// create Qt main window
EditorMainWindow main(application.get());
application->SetMainWindow(&main);
if(!singleThread)
{
// Start the Qt event loop in the d3d thread
viewerThread->start(QThread::NormalPriority);
}
// show main window
main.show();
// send qt event to game to start processing. This gets delivered thread-safe
// if qt was started in extra thread
QMetaObject::invokeMethod(application, "StartGame", Qt::QueuedConnection,
Q_ARG(QString, scene));
qtapp.exec();
//.........这里部分代码省略.........
示例5: context
void NzmqtTest::testReqRep()
{
try {
QScopedPointer<ZMQContext> context(nzmqt::createDefaultContext());
// Create replier.
samples::reqrep::Replier* replier = new samples::reqrep::Replier(*context, "inproc://reqrep", "world");
QSignalSpy spyReplierRequestReceived(replier, SIGNAL(requestReceived(const QList<QByteArray>&)));
QSignalSpy spyReplierReplySent(replier, SIGNAL(replySent(const QList<QByteArray>&)));
QSignalSpy spyReplierFailure(replier, SIGNAL(failure(const QString&)));
QSignalSpy spyReplierFinished(replier, SIGNAL(finished()));
// Create replier execution thread.
QThread* replierThread = makeExecutionThread(*replier);
QSignalSpy spyReplierThreadFinished(replierThread, SIGNAL(finished()));
// Create requester.
samples::reqrep::Requester* requester = new samples::reqrep::Requester(*context, "inproc://reqrep", "hello");
QSignalSpy spyRequesterRequestSent(requester, SIGNAL(requestSent(const QList<QByteArray>&)));
QSignalSpy spyRequesterReplyReceived(requester, SIGNAL(replyReceived(const QList<QByteArray>&)));
QSignalSpy spyRequesterFailure(requester, SIGNAL(failure(const QString&)));
QSignalSpy spyRequesterFinished(requester, SIGNAL(finished()));
// Create requester execution thread.
QThread* requesterThread = makeExecutionThread(*requester);
QSignalSpy spyRequesterThreadFinished(requesterThread, SIGNAL(finished()));
//
// START TEST
//
context->start();
replierThread->start();
QTest::qWait(500);
requesterThread->start();
QTimer::singleShot(6000, replier, SLOT(stop()));
QTimer::singleShot(6000, requester, SLOT(stop()));
QTest::qWait(8000);
//
// CHECK POSTCONDITIONS
//
qDebug() << "Requester requests sent:" << spyRequesterRequestSent.size();
qDebug() << "Replier requests received:" << spyReplierRequestReceived.size();
QCOMPARE(spyReplierFailure.size(), 0);
QCOMPARE(spyRequesterFailure.size(), 0);
QVERIFY2(spyRequesterRequestSent.size() > 3, "Requester didn't send any/enough requests.");
QCOMPARE(spyRequesterReplyReceived.size(), spyRequesterRequestSent.size());
QCOMPARE(spyReplierRequestReceived.size(), spyRequesterRequestSent.size());
QCOMPARE(spyReplierReplySent.size(), spyReplierRequestReceived.size());
QCOMPARE(spyReplierFinished.size(), 1);
QCOMPARE(spyRequesterFinished.size(), 1);
QCOMPARE(spyReplierThreadFinished.size(), 1);
QCOMPARE(spyRequesterThreadFinished.size(), 1);
}
catch (std::exception& ex)
{
QFAIL(ex.what());
}
}
示例6: QString
//.........这里部分代码省略.........
if (new_composition && composition.isEmpty()) {
dtkFatal() << "Empty composition, abort" ;
d->status = 1;
return;
}
dtkDebug() << "got composition from controller:" << composition;
if (new_composition) {
dtkDebug() << "new composition";
if (size > 1) {
dtkDebug() << "send composition to our slaves";
for (int i=1; i< size; i++) {
d->communicator_i->send(composition,i,0);
}
}
dtkDebug() << "parse composition" ;
d->reader->readString(composition);
} else {
dtkInfo() << "composition hasn't changed";
for (int i=1; i< size; i++)
d->communicator_i->send(QString("rerun"),i,0);
}
if (new_composition) {
if (dtkComposerNodeRemote *remote = dynamic_cast<dtkComposerNodeRemote *>(d->scene->root()->nodes().first()->wrapee())) {
//FIXME: can we remove this ?
// this->communicator()->setProperty("jobid",this->jobId());
remote->setSlave(this);
remote->setJob(this->jobId());
remote->setCommunicator(d->communicator_i);
} else {
dtkFatal() << "Can't find remote node in composition, abort";
d->status = 1;
return;
}
}
dtkDebug() << "run composition" ;
if (QThread::currentThread() == qApp->thread()) {
dtkTrace() << "running on main thread, create a thread for the evaluator" ;
QThread *workerThread = new QThread(this);
QObject::connect(workerThread, SIGNAL(started()), d->evaluator, SLOT(run()), Qt::DirectConnection);
QObject::connect(d->evaluator, SIGNAL(evaluationStopped()), workerThread, SLOT(quit()));
QEventLoop loop;
loop.connect(d->evaluator, SIGNAL(evaluationStopped()), &loop, SLOT(quit()));
loop.connect(qApp, SIGNAL(aboutToQuit()), &loop, SLOT(quit()));
this->socket()->moveToThread(workerThread);
workerThread->start();
loop.exec();
workerThread->wait();
workerThread->deleteLater();
} else {
dtkTrace() << "running on dedicated thread,run the evaluator" ;
d->evaluator->run_static();
}
dtkDebug() << "finished" ;
} else {
QString composition;
d->communicator_i->receive(composition,0,0);
if (composition != "rerun") {
dtkDebug() << "new/changed composition, read" ;
dtkDebug() << " composition is " << composition ;
d->reader->readString(composition);
dtkDebug() << "read done" ;
} else {
dtkDebug() << "reuse composition" ;
}
if (dtkComposerNodeRemote *remote = dynamic_cast<dtkComposerNodeRemote *>(d->scene->root()->nodes().first()->wrapee())) {
remote->setSlave(this);
remote->setJob(this->jobId());
remote->setCommunicator(d->communicator_i);
dtkDebug() << "run composition" ;
QThread *workerThread = new QThread(this);
QObject::connect(workerThread, SIGNAL(started()), d->evaluator, SLOT(run()), Qt::DirectConnection);
QObject::connect(d->evaluator, SIGNAL(evaluationStopped()), workerThread, SLOT(quit()));
QEventLoop loop;
loop.connect(d->evaluator, SIGNAL(evaluationStopped()), &loop, SLOT(quit()));
loop.connect(qApp, SIGNAL(aboutToQuit()), &loop, SLOT(quit()));
workerThread->start();
loop.exec();
workerThread->wait();
workerThread->deleteLater();
// d->evaluator->run_static();
dtkDebug() << "finished" ;
} else {
dtkFatal() << "Can't find remote node in composition, abort";
d->status = 1;
return;
}
}
}
示例7: DialogData
// calculate button is pressed
int CcgView::calculate()
{
QString command;
int retval = 0;
statusLabel.setText("Calculating...");
ui->pushButtonCalculate->setEnabled(false);
if (!globals.validData) {
DialogData * data = new DialogData(this,&globals);
data->exec();
delete data;
ui->pushButtonCalculate->setEnabled(true);
statusLabel.setText("Ready");
return -1;
}
result_filename = globals.dataDirectory + QString(PATH_SEPARATOR) + "result.png";
command = "ccg --dir " + globals.dataDirectory +
" --sites " + globals.sitesFilename +
" --filename " + result_filename +
" --width " + QString::number(image_width) +
" --height " + QString::number(image_height) +
" --subvertical " + QString::number(subtitle_vertical_position) +
" --start " + ui->spinBoxStartYear->text() +
" --end " + ui->spinBoxEndYear->text() +
" --gas \"" + ui->comboBoxGas->currentText().toLower() + "\"";
if (globals.emissionsFilename.length()>0) {
command += " --emissions \"" + globals.emissionsFilename + "\"";
}
if (globals.graphLabel.length()>0) {
command += " --label \"" + globals.graphLabel + "\"";
}
if (ui->checkBoxMinMax->isChecked()) {
command += " --minmax";
}
if (ui->checkBoxVariance->isChecked()) {
command += " --variance";
}
if (ui->checkBoxRunningAverage->isChecked()) {
command += " --runningaverage";
}
if (ui->comboBoxRegion->currentText().contains("Europe")) {
command += " --area \"60N,10W,37N,30E\"";
}
if (ui->comboBoxRegion->currentText().contains("North America")) {
command += " --area \"75N,169W,10N,55W\"";
}
if (ui->comboBoxRegion->currentText().contains("South America")) {
command += " --area \"10N,90W,55S,35W\"";
}
if (ui->comboBoxRegion->currentText().contains("Africa")) {
command += " --area \"35N,20W,35S,52E\"";
}
if (ui->comboBoxRegion->currentText().contains("Asia")) {
command += " --area \"80N,35E,5N,179E\"";
}
if ((ui->comboBoxPlotType->currentText().contains("Scatter")) ||
(ui->comboBoxPlotType->currentText().contains("Distribution"))) {
command += " --distribution";
}
if (ui->comboBoxPlotType->currentText().contains("Altitude")) {
command += " --altitudes";
}
if (ui->comboBoxPlotType->currentText().contains("Change")) {
command += " --change";
}
if ((ui->comboBoxPlotType->currentText().contains("monthly")) ||
(ui->comboBoxPlotType->currentText().contains("Monthly"))) {
command += " --monthly";
}
if (ui->comboBoxRegion->currentText().contains("Arctic Circle")) {
command += " --latitudes \"90N,66N\"";
}
if (ui->comboBoxRegion->currentText().contains("Northern Hemisphere")) {
command += " --latitudes \"90N,0N\"";
}
if (ui->comboBoxRegion->currentText().contains("Southern Hemisphere")) {
command += " --latitudes \"0S,90S\"";
}
if (ui->comboBoxRegion->currentText().contains("Equatorial")) {
command += " --latitudes \"10N,10S\"";
}
qDebug("%s", command.toStdString().c_str());
QThread* thread = new QThread;
ThreadCalculate* calc = new ThreadCalculate();
calc->command = command;
calc->image_filename = result_filename;
calc->moveToThread(thread);
connect(thread, SIGNAL(started()), calc, SLOT(process()));
connect(calc, SIGNAL(finished()), thread, SLOT(quit()));
connect(calc, SIGNAL(finished()), calc, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(calc, SIGNAL(finished()), this, SLOT(showGraph()));
//.........这里部分代码省略.........
示例8: INoteView
//.........这里部分代码省略.........
commentPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
m_comments->setPage(commentPage);
m_comments->history()->setMaximumItemCount(0);
m_comments->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
m_comments->settings()->globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
m_comments->settings()->globalSettings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
m_comments->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
m_comments->setAcceptDrops(false);
connect(m_comments, SIGNAL(loadFinished(bool)), m_title, SLOT(onCommentPageLoaded(bool)));
connect(m_comments, SIGNAL(linkClicked(QUrl)), m_web, SLOT(onEditorLinkClicked(QUrl)));
connect(m_comments->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
SLOT(on_comment_populateJavaScriptWindowObject()));
m_commentWidget->hide();
layoutDoc->addWidget(m_title);
layoutDoc->addWidget(m_splitter);
layoutDoc->setStretchFactor(m_title, 0);
layoutDoc->setStretchFactor(m_splitter, 1);
#ifdef USEWEBENGINE
QLineEdit *commandLine = new QLineEdit(this);
layoutDoc->addWidget(commandLine);
connect(commandLine, SIGNAL(returnPressed()), SLOT(on_command_request()));
#endif
QVBoxLayout* layoutMain = new QVBoxLayout(this);
layoutMain->setContentsMargins(0, 0, 0, 0);
setLayout(layoutMain);
layoutMain->addWidget(m_tab);
//
layoutMain->addWidget(m_transitionView);
m_transitionView->hide();
MainWindow* mainWindow = qobject_cast<MainWindow *>(m_app.mainWindow());
m_downloaderHost = mainWindow->downloaderHost();
connect(m_downloaderHost, SIGNAL(downloadDone(const WIZOBJECTDATA&, bool)),
SLOT(on_download_finished(const WIZOBJECTDATA&, bool)));
connect(&m_dbMgr, SIGNAL(documentModified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&)), \
SLOT(on_document_modified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&)));
connect(&m_dbMgr, SIGNAL(documentDataModified(const WIZDOCUMENTDATA&)),
SLOT(on_document_data_modified(const WIZDOCUMENTDATA&)));
connect(&m_dbMgr, SIGNAL(attachmentCreated(const WIZDOCUMENTATTACHMENTDATA&)), \
SLOT(on_attachment_created(const WIZDOCUMENTATTACHMENTDATA&)));
connect(&m_dbMgr, SIGNAL(attachmentDeleted(const WIZDOCUMENTATTACHMENTDATA&)), \
SLOT(on_attachment_deleted(const WIZDOCUMENTATTACHMENTDATA&)));
connect(&m_dbMgr, SIGNAL(documentUploaded(QString,QString)), \
m_editStatusSyncThread, SLOT(documentUploaded(QString,QString)));
connect(Core::ICore::instance(), SIGNAL(viewNoteRequested(Core::INoteView*,const WIZDOCUMENTDATA&)),
SLOT(onViewNoteRequested(Core::INoteView*,const WIZDOCUMENTDATA&)));
connect(Core::ICore::instance(), SIGNAL(viewNoteLoaded(Core::INoteView*,WIZDOCUMENTDATA,bool)),
SLOT(onViewNoteLoaded(Core::INoteView*,const WIZDOCUMENTDATA&,bool)));
connect(Core::ICore::instance(), SIGNAL(closeNoteRequested(Core::INoteView*)),
SLOT(onCloseNoteRequested(Core::INoteView*)));
connect(m_web, SIGNAL(focusIn()), SLOT(on_webView_focus_changed()));
connect(m_title, SIGNAL(notifyBar_link_clicked(QString)), SLOT(on_notifyBar_link_clicked(QString)));
connect(m_title, SIGNAL(loadComment_request(QString)), SLOT(on_loadComment_request(QString)), Qt::QueuedConnection);
// connect(m_editStatusCheckThread, SIGNAL(checkFinished(QString,QStringList)),
// SLOT(on_checkEditStatus_finished(QString,QStringList)));
// connect(m_editStatusCheckThread, SIGNAL(checkDocumentChangedFinished(QString,bool)),
// SLOT(on_checkDocumentChanged_finished(QString,bool)));
// connect(m_editStatusCheckThread, SIGNAL(checkTimeOut(QString)),
// SLOT(on_checkEditStatus_timeout(QString)));
//
m_editStatusSyncThread->start(QThread::IdlePriority);
// m_editStatusCheckThread->start(QThread::IdlePriority);
m_editStatusChecker = new CWizDocumentStatusChecker();
connect(this, SIGNAL(checkDocumentEditStatusRequest(QString,QString)), m_editStatusChecker,
SLOT(checkEditStatus(QString,QString)));
connect(this, SIGNAL(stopCheckDocumentEditStatusRequest(QString,QString)),
m_editStatusChecker, SLOT(stopCheckStatus(QString,QString)));
connect(m_editStatusChecker, SIGNAL(checkEditStatusFinished(QString,bool)), \
SLOT(on_checkEditStatus_finished(QString,bool)));
connect(m_editStatusChecker, SIGNAL(checkTimeOut(QString)), \
SLOT(on_checkEditStatus_timeout(QString)));
connect(m_editStatusChecker, SIGNAL(documentEditingByOthers(QString,QStringList)), \
SLOT(on_documentEditingByOthers(QString,QStringList)));
connect(m_editStatusChecker, SIGNAL(checkDocumentChangedFinished(QString,bool)), \
SLOT(on_checkDocumentChanged_finished(QString,bool)));
QThread* checkThread = new QThread(this);
connect(checkThread, SIGNAL(started()), m_editStatusChecker, SLOT(initialise()));
connect(checkThread, SIGNAL(finished()), m_editStatusChecker, SLOT(clearTimers()));
m_editStatusChecker->moveToThread(checkThread);
checkThread->start();
}
示例9: memset
bool Commands::Run(const QString & filename, int data_rate, bool loopinput)
{
QString cmd;
int ret;
int poll_cnt = 1;
struct pollfd polls[2];
memset(polls, 0, sizeof(polls));
polls[0].fd = 0;
polls[0].events = POLLIN | POLLPRI;
polls[0].revents = 0;
m_fileName = filename;
m_streamer = new Streamer(this, m_fileName, data_rate, loopinput);
QThread *streamThread = new QThread(this);
m_streamer->moveToThread(streamThread);
connect(streamThread, SIGNAL(finished(void)),
m_streamer, SLOT(deleteLater(void)));
connect(this, SIGNAL(SendBytes(void)),
m_streamer, SLOT(SendBytes(void)));
streamThread->start();
QFile input;
input.open(stdin, QIODevice::ReadOnly);
QTextStream qtin(&input);
LOG(VB_RECORD, LOG_INFO, LOC + "Listening for commands");
while (m_run)
{
ret = poll(polls, poll_cnt, m_timeout);
if (polls[0].revents & POLLHUP)
{
LOG(VB_RECORD, LOG_ERR, LOC + "poll eof (POLLHUP)");
break;
}
else if (polls[0].revents & POLLNVAL)
{
LOG(VB_RECORD, LOG_ERR, LOC + "poll error");
return false;
}
if (polls[0].revents & POLLIN)
{
if (ret > 0)
{
cmd = qtin.readLine();
if (!process_command(cmd))
{
streamThread->quit();
streamThread->wait();
delete streamThread;
streamThread = NULL;
m_streamer = NULL;
m_run = false;
}
}
else if (ret < 0)
{
if ((EOVERFLOW == errno))
{
LOG(VB_RECORD, LOG_ERR, LOC + "command overflow.");
break; // we have an error to handle
}
if ((EAGAIN == errno) || (EINTR == errno))
{
LOG(VB_RECORD, LOG_ERR, LOC + "retry command read.");
continue; // errors that tell you to try again
}
LOG(VB_RECORD, LOG_ERR, LOC + "unknown error reading command.");
}
}
}
return true;
}
示例10: while
// this routine will be called now every 10 seconds to update the cartesianplot
// however when many data it may take much longer, then suppress any new request
void ArchiveCA_Plugin::Callback_UpdateInterface( QMap<QString, indexes> listOfIndexes)
{
int nbVal;
precision = 5;
// Index name
stdString index_name = "/gfa/archiver-data/archive_PRO_ST/index";
//qDebug() << "====================== ArchiveCA_Plugin::Callback_UpdateInterface";
QMap<QString, indexes>::const_iterator i = listOfIndexes.constBegin();
while (i != listOfIndexes.constEnd()) {
QThread *tmpThread = (QThread *) 0;
indexes indexNew = i.value();
//qDebug() << i.key() << ": " << indexNew.indexX << indexNew.indexY << indexNew.pv << indexNew.w << endl;
nbVal = 0;
QMap<QString, QThread *>::iterator j = listOfThreads.find(indexNew.key);
while (j !=listOfThreads.end() && j.key() == indexNew.key) {
tmpThread = (QThread *) j.value();
++j;
}
//qDebug() << "tmpThread" << tmpThread;
if((tmpThread != (QThread *) 0) && tmpThread->isRunning()) {
//qDebug() << "workerthread is running" << tmpThread->isRunning();
} else {
// Get Index name if specified for this widget
if(caCartesianPlot* w = qobject_cast<caCartesianPlot *>((QWidget*) indexNew.w)) {
QVariant var = w->property("archiverIndex");
if(!var.isNull()) {
QString indexName = var.toString();
index_name = qasc(indexName);
} else if(indexNew.init){
QString mess("ArchiveCA plugin -- no archiverIndex defined as dynamic property in widget " + w->objectName() + ", defaulting to /gfa/archiver-data/archive_PRO_ST/index");
if(messagewindowP != (MessageWindow *) 0) messagewindowP->postMsgEvent(QtWarningMsg, (char*) qasc(mess));
}
}
WorkerCA *worker = new WorkerCA;
QThread *tmpThread = new QThread;
listOfThreads.insert(i.key(), tmpThread);
worker->moveToThread(tmpThread);
connect(tmpThread, SIGNAL(finished()), worker, SLOT(workerFinish()));
connect(tmpThread, SIGNAL(finished()), tmpThread, SLOT(deleteLater()) );
connect(this, SIGNAL(operate( QWidget *, indexes, const stdString)), worker,
SLOT(getFromArchive(QWidget *, indexes, stdString)));
connect(worker, SIGNAL(resultReady(indexes, int, QVector<double>, QVector<double>, QString)), this,
SLOT(handleResults(indexes, int, QVector<double>, QVector<double>, QString)));
tmpThread->start();
//qDebug() << "CA emit operate";
emit operate((QWidget *) messagewindowP ,indexNew, index_name);
}
++i;
}
}
示例11: tr
void WidgetMain::slotClickUpload()
{
{
//如果存在串口监视的则暂停
if(NULL != pSerialPortTool_)
{
pSerialPortTool_->closePort();
pSerialPortTool_->close();
}
}
//加入是否已经设置好串口的判断
if(pSerialSetting_->getBoardType() == tr("Plase Set Arduino Type")
|| pSerialSetting_->getSerialPort() == tr("Serial Port"))
{
//在此调出串口设置界面让其设置
createUploadSetting();
}
else
{
UploadWaitForm *p = new UploadWaitForm(this->rect(), this);
p->setAttribute(Qt::WA_DeleteOnClose);
QSettings settingTmp("./resource/setting.ini", QSettings::IniFormat);
QString value = settingTmp.value(tr("Normal/uploader")).toString();
QString filePath;
if(value == "ArduinoUploader")
{
#ifdef Q_OS_MAC
QDir dir("./resource/tools/ArduinoUploader/ArduinoUploader.app/Contents/MacOS");
if(!dir.exists("Temp"))
{
dir.mkdir("Temp");
}
filePath = "./resource/tools/ArduinoUploader/ArduinoUploader.app/Contents/MacOS/Temp/code.cpp";
#else
QDir dir("./resource/tools/ArduinoUploader");
if(!dir.exists("Temp"))
{
dir.mkdir("Temp");
}
filePath = "./resource/tools/ArduinoUploader/Temp/code.cpp";
#endif
}
else if(value == "DFRobotUploader")
{
#ifdef Q_OS_MAC
QDir dir("./resource/tools/ArduinoUploader/ArduinoUploader.app/Contents/MacOS");
if(!dir.exists("Temp"))
{
dir.mkdir("Temp");
}
filePath = "./resource/tools/ArduinoUploader/ArduinoUploader.app/Contents/MacOS/Temp/code.cpp";
#else
QDir dir("./resource/tools/ArduinoUploader");
if(!dir.exists("Temp"))
{
dir.mkdir("Temp");
}
filePath = "./resource/tools/ArduinoUploader/Temp/code.cpp";
#endif
}
Uploader *pUpload = new Uploader(filePath, boardIndex_, pSerialSetting_->getSerialPort());
QThread *pThread = new QThread;
pUpload->moveToThread(pThread);
connect(pThread, SIGNAL(started()), pUpload, SLOT(slotStart()));
connect(pUpload, SIGNAL(signalCurrentProgress(float, int)), p, SLOT(slotAdvanceProgress(float,int)), Qt::QueuedConnection);
connect(pUpload, SIGNAL(signalBoardError(QString)), p, SLOT(SlotBoardError(QString)), Qt::QueuedConnection);
connect(pUpload, SIGNAL(signalTypeConversionError(QString)), p, SLOT(SlotTypeConversionError(QString)), Qt::QueuedConnection);
connect(pUpload, SIGNAL(signalPortError(QString)), p, SLOT(SlotPortError(QString)), Qt::QueuedConnection);
connect(pUpload, SIGNAL(signalCompileEnd()), p, SLOT(SlotCompileEnd()));
connect(p, SIGNAL(signalCancel()), pThread, SLOT(terminate()));
p->show();
pThread->start();
}
}
示例12: while
void AssignmentClient::readPendingDatagrams() {
NodeList* nodeList = NodeList::getInstance();
QByteArray receivedPacket;
HifiSockAddr senderSockAddr;
while (nodeList->getNodeSocket().hasPendingDatagrams()) {
receivedPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
nodeList->getNodeSocket().readDatagram(receivedPacket.data(), receivedPacket.size(),
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
if (packetVersionMatch(receivedPacket)) {
if (_currentAssignment) {
// have the threaded current assignment handle this datagram
QMetaObject::invokeMethod(_currentAssignment, "processDatagram", Qt::QueuedConnection,
Q_ARG(QByteArray, receivedPacket),
Q_ARG(HifiSockAddr, senderSockAddr));
} else if (packetTypeForPacket(receivedPacket) == PacketTypeCreateAssignment) {
if (_currentAssignment) {
qDebug() << "Dropping received assignment since we are currently running one.";
} else {
// construct the deployed assignment from the packet data
_currentAssignment = AssignmentFactory::unpackAssignment(receivedPacket);
if (_currentAssignment) {
qDebug() << "Received an assignment -" << *_currentAssignment;
// switch our nodelist domain IP and port to whoever sent us the assignment
nodeList->setDomainSockAddr(senderSockAddr);
nodeList->setOwnerUUID(_currentAssignment->getUUID());
qDebug() << "Destination IP for assignment is" << nodeList->getDomainIP().toString();
// start the deployed assignment
QThread* workerThread = new QThread(this);
connect(workerThread, SIGNAL(started()), _currentAssignment, SLOT(run()));
connect(_currentAssignment, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
connect(_currentAssignment, SIGNAL(finished()), workerThread, SLOT(quit()));
connect(_currentAssignment, SIGNAL(finished()), _currentAssignment, SLOT(deleteLater()));
connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
_currentAssignment->moveToThread(workerThread);
// move the NodeList to the thread used for the _current assignment
nodeList->moveToThread(workerThread);
// Starts an event loop, and emits workerThread->started()
workerThread->start();
} else {
qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
}
}
} else {
// have the NodeList attempt to handle it
nodeList->processNodeData(senderSockAddr, receivedPacket);
}
}
}
}
示例13: QSplitter
MainWidget::MainWidget( QWidget *parent )
: QSplitter( Qt::Horizontal, parent )
, mpKryptonite( new Kryptonite() )
, mpAmazonDE( new KryptoniteJobCoverAmazonDE( mpKryptonite ) )
, mpDiscogs( new KryptoniteJobCoverDiscogs( mpKryptonite ) )
, mpLayout( new QGridLayout( this ) )
, mpFileSysTree( new QTreeView( this ) )
, mpFileSysModel( new QFileSystemModel( this ) )
, mpLineEdit( new QLineEdit( this ) )
, mpFollowPartyman( new QCheckBox( tr("Follow Partyman"), this ) )
, mpCopyBuffer( new QPushButton( tr("Copy debug buffer to clipboard"), this ) )
, mpImage( new DropImageWidget( this ) )
, mpInfo( new QListWidget( this ) )
, mpSignalMapper( new QSignalMapper( this ) )
, mDataMap()
, mCacheMap()
, mDebugData()
{
mpKryptonite->setObjectName( "Downloader");
mpAmazonDE->setObjectName( "Amazon" );
mpDiscogs->setObjectName( "Discogs" );
mpFileSysTree->setObjectName( "FileSysTree" );
mpFileSysModel->setObjectName( "FileSysModel" );
mpLineEdit->setObjectName( "LineInput" );
mpFollowPartyman->setObjectName( "FollowPartyman" );
mpFollowPartyman->setChecked( true );
mpCopyBuffer->setObjectName( "CopyBuffer" );
mpImage->setObjectName( "Image" );
mpInfo->setObjectName( "Info" );
QThread *t = new QThread();
connect( qApp, SIGNAL(aboutToQuit()),
t, SLOT(quit()) );
ProxyWidget::setProxy( mpKryptonite->networkAccessManager() );
mpKryptonite->moveToThread( t );
mpAmazonDE->moveToThread( t );
mpDiscogs->moveToThread( t );
t->setObjectName( "DownloadThread" );
t->start();
QWidget *w = 0;
mpFileSysTree->setModel( mpFileSysModel );
mpFileSysModel->setRootPath( "/" );
mpFileSysModel->setFilter( QDir::NoDotAndDotDot | QDir::AllDirs );
const QString current( Settings::value( Settings::RubberbandmanRootDirectory ) );
QModelIndex qmi( mpFileSysModel->index( current ) );
if( qmi.isValid() )
{
mpFileSysTree->setRootIndex( qmi );
mpFileSysTree->setCurrentIndex( mpFileSysModel->index( current ) );
}
mpFileSysTree->header()->hide();
mpFileSysTree->setColumnHidden( 1, true );
mpFileSysTree->setColumnHidden( 2, true );
mpFileSysTree->setColumnHidden( 3, true );
QSplitter *s = new QSplitter( Qt::Vertical, this );
w = new QWidget( this );
QVBoxLayout *v = new QVBoxLayout( w );
v->addWidget( mpFileSysTree );
v->addWidget( mpLineEdit );
QHBoxLayout *h = new QHBoxLayout();
v->addLayout( h );
h->addWidget( mpFollowPartyman );
h->addWidget( mpCopyBuffer );
s->addWidget( w );
w = new QWidget( this );
w->setLayout( mpLayout );
s->addWidget( w );
addWidget( s );
w = new QWidget( this );
v = new QVBoxLayout( w );
v->addWidget( mpImage );
v->addWidget( mpInfo );
addWidget( w );
v->setStretch( 0, 1 );
Satellite *satellite = Satellite::get();
connect( mpImage, SIGNAL(droppedUrl(QUrl)),
this, SLOT(saveImage(QUrl)) );
connect( mpCopyBuffer, SIGNAL(clicked()),
this, SLOT(debugBufferToClipboard()) );
connect( mpLineEdit, SIGNAL(returnPressed()),
this, SLOT(requestFromLine()) );
connect( mpFileSysTree, SIGNAL(clicked(QModelIndex)),
this, SLOT(entryClicked(QModelIndex)) );
connect( mpSignalMapper, SIGNAL(mapped(QWidget*)),
this, SLOT(saveImage(QWidget*)) );
connect( this, SIGNAL(requestSearch(QString)),
mpDiscogs, SLOT(requestList(QString)) );
connect( mpDiscogs, SIGNAL(imageFound(QByteArray,QVariant)),
this, SLOT(addThumbnail(QByteArray,QVariant)) );
connect( mpDiscogs, SIGNAL(imageDownloaded(QByteArray,QVariant)),
this, SLOT(showImage(QByteArray,QVariant)) );
connect( mpDiscogs, SIGNAL(message(QString,QByteArray)),
this, SLOT(message(QString,QByteArray)) );
connect( this, SIGNAL(requestSearch(QString)),
mpAmazonDE, SLOT(requestList(QString)) );
connect( mpAmazonDE, SIGNAL(imageFound(QByteArray,QVariant)),
this, SLOT(addThumbnail(QByteArray,QVariant)) );
connect( mpAmazonDE, SIGNAL(imageDownloaded(QByteArray,QVariant)),
this, SLOT(showImage(QByteArray,QVariant)) );
//.........这里部分代码省略.........
示例14: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//about window
this->aboutWindow = new AboutWindow();
this->aboutWindow->hide();
this->aboutWindow->move(this->geometry().center()-this->aboutWindow->geometry().center());
//calibrate Dialog
this->calibrateDialog = new CalibrateDialog();
this->calibrateDialog->hide();
this->calibrateDialog->move(this->geometry().center()-this->calibrateDialog->geometry().center());
//option Dialog
this->optionDialog = new OptionDialog();
this->optionDialog->hide();
this->optionDialog->move(this->geometry().center()-this->optionDialog->geometry().center());
//slice dialog
this->sliceDialog = new SliceDialog(ui->glWidget, this);
this->sliceDialog->hide();
this->sliceDialog->move(this->geometry().center()-this->sliceDialog->geometry().center());
connect(this->optionDialog, SIGNAL(slicerPathChanged(QString)), this->sliceDialog, SLOT(updateSlicerPath(QString)));
connect(this->optionDialog, SIGNAL(outputPathChanged(QString)), this->sliceDialog, SLOT(updateOutputPath(QString)));
connect(this->optionDialog, SIGNAL(newSize(QVector3D)), this, SLOT(updatadeSize(QVector3D)));
connect(this->optionDialog, SIGNAL(newList(QList<Material*>*)), this->sliceDialog, SLOT(setMaterialList(QList<Material*>*)));
connect(this->sliceDialog, SIGNAL(fileSliced(QString)), this, SLOT(loadFile(QString)));
//set version number
this->setWindowTitle("YARRH v"+QString::number(VERSION_MAJOR)+"."+QString::number(VERSION_MINOR)+"."+QString::number(VERSION_REVISION));
this->aboutWindow->setVersion(VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION);
//setting up printer and its thread
this->printerObj = new Printer();
QThread *qthread = new QThread();
//connecting ui to printer
connect(printerObj, SIGNAL(write_to_console(QString)), ui->inConsole, SLOT(appendPlainText(QString)), Qt::QueuedConnection);
connect(ui->fanSpinBox, SIGNAL(valueChanged(int)), printerObj, SLOT(setFan(int)), Qt::QueuedConnection);
ui->fanSpinBox->blockSignals(true);
//connecting move btns
connect(ui->homeX, SIGNAL(clicked()), printerObj, SLOT(homeX()), Qt::QueuedConnection);
connect(ui->homeY, SIGNAL(clicked()), printerObj, SLOT(homeY()), Qt::QueuedConnection);
connect(ui->homeAll, SIGNAL(clicked()), printerObj, SLOT(homeAll()), Qt::QueuedConnection);
//connect monit temp checkbox
connect(ui->graphGroupBox, SIGNAL(toggled(bool)), printerObj, SLOT(setMonitorTemperature(bool)),Qt::QueuedConnection);
//connect printer to temp widget
connect(printerObj, SIGNAL(currentTemp(double,double,double)), this, SLOT(drawTemp(double,double,double)));
connect(printerObj, SIGNAL(progress(int)), this, SLOT(updateProgress(int)));
connect(printerObj, SIGNAL(connected(bool)), this, SLOT(printerConnected(bool)));
//setting ui temp from gcode
connect(printerObj, SIGNAL(settingTemp1(double)), this, SLOT(setTemp1FromGcode(double)));
connect(printerObj, SIGNAL(settingTemp3(double)), this, SLOT(setTemp3FromGcode(double)));
//updating head position in ui
connect(printerObj, SIGNAL(currentPosition(QVector3D)), this, SLOT(updateHeadPosition(QVector3D)));
//print finished signal
connect(printerObj, SIGNAL(printFinished(bool)), this, SLOT(printFinished(bool)));
//connect calibration dialog to printer
connect(calibrateDialog, SIGNAL(writeToPrinter(QString)), printerObj, SLOT(send_now(QString)),Qt::QueuedConnection);
//connect z slider
connect(ui->zSlider, SIGNAL(valueChanged(int)), this, SLOT(moveZ(int)));
connect(ui->zSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateZ(int)));
//connect action load
connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(loadFile()));
printerObj->moveToThread(qthread);
qthread->start(QThread::HighestPriority);
this->portEnum = new QextSerialEnumerator(this);
this->portEnum->setUpNotifications();
QList<QextPortInfo> ports = this->portEnum->getPorts();
//finding avalible ports
foreach (QextPortInfo info, ports) {
ui->portCombo->addItem(info.portName);
}
示例15: while
void AssignmentClient::readPendingDatagrams() {
auto nodeList = DependencyManager::get<NodeList>();
QByteArray receivedPacket;
HifiSockAddr senderSockAddr;
while (nodeList->getNodeSocket().hasPendingDatagrams()) {
receivedPacket.resize(nodeList->getNodeSocket().pendingDatagramSize());
nodeList->getNodeSocket().readDatagram(receivedPacket.data(), receivedPacket.size(),
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
if (packetTypeForPacket(receivedPacket) == PacketTypeCreateAssignment) {
qDebug() << "Received a PacketTypeCreateAssignment - attempting to unpack.";
// construct the deployed assignment from the packet data
_currentAssignment = AssignmentFactory::unpackAssignment(receivedPacket);
if (_currentAssignment) {
qDebug() << "Received an assignment -" << *_currentAssignment;
// switch our DomainHandler hostname and port to whoever sent us the assignment
nodeList->getDomainHandler().setSockAddr(senderSockAddr, _assignmentServerHostname);
nodeList->getDomainHandler().setAssignmentUUID(_currentAssignment->getUUID());
qDebug() << "Destination IP for assignment is" << nodeList->getDomainHandler().getIP().toString();
// start the deployed assignment
QThread* workerThread = new QThread;
workerThread->setObjectName("ThreadedAssignment Worker");
connect(workerThread, &QThread::started, _currentAssignment.data(), &ThreadedAssignment::run);
// Once the ThreadedAssignment says it is finished - we ask it to deleteLater
// This is a queued connection so that it is put into the event loop to be processed by the worker
// thread when it is ready.
connect(_currentAssignment.data(), &ThreadedAssignment::finished, _currentAssignment.data(),
&ThreadedAssignment::deleteLater, Qt::QueuedConnection);
// once it is deleted, we quit the worker thread
connect(_currentAssignment.data(), &ThreadedAssignment::destroyed, workerThread, &QThread::quit);
// have the worker thread remove itself once it is done
connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
// once the worker thread says it is done, we consider the assignment completed
connect(workerThread, &QThread::destroyed, this, &AssignmentClient::assignmentCompleted);
_currentAssignment->moveToThread(workerThread);
// move the NodeList to the thread used for the _current assignment
nodeList->moveToThread(workerThread);
// let the assignment handle the incoming datagrams for its duration
disconnect(&nodeList->getNodeSocket(), 0, this, 0);
connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, _currentAssignment.data(),
&ThreadedAssignment::readPendingDatagrams);
// Starts an event loop, and emits workerThread->started()
workerThread->start();
} else {
qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
}
} else if (packetTypeForPacket(receivedPacket) == PacketTypeStopNode) {
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
qDebug() << "AssignmentClientMonitor at" << senderSockAddr << "requested stop via PacketTypeStopNode.";
QCoreApplication::quit();
} else {
qDebug() << "Got a stop packet from other than localhost.";
}
} else {
// have the NodeList attempt to handle it
nodeList->processNodeData(senderSockAddr, receivedPacket);
}
}
}
}