コード例 #1
0
void Thread::run()
{
  m_commandQueue = new CommandQueue(this);
  m_settings = new Settings();
  setCurrentProtocol("ftp");
  m_startupSem.release();
  
  // Enter the event loop
  QEventLoop eventLoop;
  while (!m_exit) {
    if (m_commandsDeferred)
      eventLoop.processEvents(QEventLoop::ProcessEventsFlag(QEventLoop::DeferredDeletion));
    else
      eventLoop.processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::ProcessEventsFlag(QEventLoop::DeferredDeletion));
    
    if (m_commandsDeferred) {
      m_socket->nextCommand();
      m_commandsDeferred--;
    }
  }
  
  // Cleanup before exiting
  delete m_settings;
  delete m_commandQueue;
  
  foreach (Socket *socket, m_sockets) {
    delete socket;
  }

  // Schedule our deletion
  deleteLater();
}
コード例 #2
0
ファイル: GeneratorDaemon.cpp プロジェクト: 4ukuta/core
void GeneratorDaemon::run()
{
  qDebug() << "thread started";
  QEventLoop eventLoop;
  m_loginQuery = new LoginQuery("DemoUser", "test", this);
  connect(m_loginQuery, SIGNAL(connected()), SLOT(onConnected()));
  connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  m_loginQuery->doRequest();
  for (;;)
  {
    if (m_isConnected)
    {
      qDebug() << "connected: auth_token=" << m_loginQuery->getUser()->getToken();
      qDebug() << "tagQuery " << m_tagQuery;
      if (m_tagQuery)
      {
        for (int i=0;i<m_marks.size();i++)
        {
          m_tagQuery->getTag()->setTime(QDateTime::currentDateTime());
          m_tagQuery->getTag()->setLatitude(m_marks.at(i).x());
          m_tagQuery->getTag()->setLongitude(m_marks.at(i).y());
          m_tagQuery->doRequest();
          qDebug() << "adding mark";
          eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
          QThread::msleep(5000);
        }
      }
    }
    eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
    QThread::msleep(5000);
  }
}
コード例 #3
0
void eventLoop(QApplication& a, Engine& engine) {
    QEventLoop loop;

    while(running()) {
        a.sendPostedEvents();
        loop.processEvents(QEventLoop::WaitForMoreEvents);
        while (engine.isRunnable()) {
            engine.interpret();
            a.sendPostedEvents();
            loop.processEvents(QEventLoop::AllEvents);
        }
    }
}
コード例 #4
0
ファイル: ndns.cpp プロジェクト: serghei/kde3-kdenetwork
void NDnsManager::app_aboutToQuit()
{
	while(man) {
		QEventLoop *e = qApp->eventLoop();
		e->processEvents(QEventLoop::WaitForMore);
	}
}
コード例 #5
0
bool DirtyListExecutor::eraseRoad(Way *R)
{
    Progress->setValue(++Done);

    qDebug() << QString("REMOVE road %1").arg(R->id().numId);

    Progress->setLabelText(tr("REMOVE road %1").arg(R->id().numId) + userName(R));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);
//	QString URL("/api/0.3/way/%1");
//	URL = URL.arg(stripToOSMId(R->id()));
    QString URL = theDownloader->getURLToDelete("way",stripToOSMId(R->id()));
    QString DataIn, DataOut;
    DataIn = wrapOSM(exportOSM(*R, ChangeSetId), ChangeSetId);
    if (sendRequest("DELETE",URL,DataIn,DataOut))
    {
        R->setLastUpdated(Feature::OSMServer);
        if (!g_Merk_Frisius) {
            R->layer()->remove(R);
            document()->getUploadedLayer()->add(R);
        }
        R->setUploaded(true);
        R->setDirtyLevel(0);
        return EraseFromHistory;
    }
    return false;
}
コード例 #6
0
bool DirtyListExecutor::updatePoint(Node* Pt)
{
    Progress->setValue(++Done);

    qDebug() << QString("UPDATE trackpoint %1").arg(Pt->id().numId);

    Progress->setLabelText(tr("UPDATE trackpoint %1").arg(Pt->id().numId) + userName(Pt));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);
//	QString URL("/api/0.3/node/%1");
//	URL = URL.arg(stripToOSMId(Pt->id()));
    QString URL = theDownloader->getURLToUpdate("node",stripToOSMId(Pt->id()));
    QString DataIn, DataOut;
    DataIn = wrapOSM(exportOSM(*Pt, ChangeSetId), ChangeSetId);
    if (sendRequest("PUT",URL,DataIn,DataOut))
    {
        Pt->setLastUpdated(Feature::OSMServer);

        int NewVersion = DataOut.toInt();
        if (NewVersion <= Pt->versionNumber())
            NewVersion = Pt->versionNumber()+1;
        Pt->setVersionNumber(NewVersion);

        if (!g_Merk_Frisius) {
            Pt->layer()->remove(Pt);
            document()->getUploadedLayer()->add(Pt);
        }
        Pt->setUploaded(true);
        Pt->setDirtyLevel(0);
        return EraseFromHistory;
    }
    return false;
}
コード例 #7
0
bool DirtyListExecutor::updateRoad(Way* R)
{
    Progress->setValue(++Done);

    qDebug() << QString("UPDATE road %1").arg(R->id().numId);

    Progress->setLabelText(tr("UPDATE road %1").arg(R->id().numId) + userName(R));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);
    QString URL = theDownloader->getURLToUpdate("way",stripToOSMId(R->id()));
    QString DataIn, DataOut;
    DataIn = wrapOSM(exportOSM(*R, ChangeSetId), ChangeSetId);
    if (sendRequest("PUT",URL,DataIn,DataOut))
    {
        R->setLastUpdated(Feature::OSMServer);

        int NewVersion = DataOut.toInt();
        if (NewVersion <= R->versionNumber())
            NewVersion = R->versionNumber()+1;
        R->setVersionNumber(NewVersion);

        if (!g_Merk_Frisius) {
            R->layer()->remove(R);
            document()->getUploadedLayer()->add(R);
        }
        R->setUploaded(true);
        R->setDirtyLevel(0);
        return EraseFromHistory;
    }
    return true;
}
コード例 #8
0
bool DirtyListExecutor::addPoint(Node* Pt)
{
    Progress->setValue(++Done);

    qDebug() << QString("ADD trackpoint %1").arg(Pt->id().numId);

    Progress->setLabelText(tr("ADD trackpoint %1").arg(Pt->id().numId) + userName(Pt));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);

    QString DataIn, DataOut;
    IFeature::FId OldId;
    OldId = Pt->id();
    Pt->setId(IFeature::FId(IFeature::Point, 0));
    DataIn = wrapOSM(exportOSM(*Pt, ChangeSetId), ChangeSetId);
    Pt->setId(OldId);
    QString URL=theDownloader->getURLToCreate("node");
    if (sendRequest("PUT",URL,DataIn,DataOut))
    {
        // chop off extra spaces, newlines etc
        Pt->setId(IFeature::FId(IFeature::Point, DataOut.toInt()));
        Pt->setLastUpdated(Feature::OSMServer);
        Pt->setVersionNumber(1);
        if (!g_Merk_Frisius) {
            Pt->layer()->remove(Pt);
            document()->getUploadedLayer()->add(Pt);
        }
        Pt->setUploaded(true);
        Pt->setDirtyLevel(0);
        return EraseFromHistory;
    }
    return false;
}
コード例 #9
0
ファイル: phpwebview.cpp プロジェクト: scraperlab/browserext
int PhpWebView::click2(QWebElement elem, bool samewnd)
{
	if (elem.isNull())
		return 0;

	if (samewnd)
		elem.removeAttribute("target");

	QEventLoop loop;
	isNewViewCreated = false;
	isNewViewBegin = false;
	
	QString js = "var e = document.createEvent('MouseEvents');";
	//js += "e.initEvent( 'click', true, true );";
    js += "e.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);";
    js += "this.dispatchEvent(e);";
	elem.evaluateJavaScript(js);
	
	QTimer::singleShot(1000, &loop, SLOT(quit()));
	loop.exec();
	
	while (browser && isNewViewBegin && !isNewViewCreated)
		loop.processEvents();

	return 1;
}
コード例 #10
0
/**
  * @brief Fetch the raw list of DNS resolvers and return them as strings.
  */
QStringList OpenNICSystem::getBootstrapT2List()
{
    QStringList outputList;
    QStringList ips;
    QEventLoop loop;
    QString program = "dig";
    QStringList arguments;
    QString output;
    arguments << "dns.opennic.glue" << "+short";
    QProcess* process = new QProcess();
    process->start(program, arguments);
    while (process->waitForFinished(15000))
    {
        loop.processEvents();
    }
    output = process->readAllStandardOutput();
    outputList = output.trimmed().split('\n');
    for(int n=0; n < outputList.count(); n++)
    {
        QString ip = outputList.at(n).trimmed();
        if ( ip.length() )
        {
            if (ip.at(0) >= '0' && ip.at(0) <= '9')
            {
                ips.append(ip);
            }
        }
    }
    delete process;
    return ips;
}
コード例 #11
0
/**
  * @brief Add a dns entry to the system's list of DNS resolvers.
  * @param resolver The IP address of teh resolver to add to the system
  * @param index resolver sequence (1..n)
  */
int OpenNICSystem::updateResolver(QHostAddress& resolver,int index,QString& output)
{
    int rc;
    QEventLoop loop;
    QString program = "netsh";
    QStringList arguments;
    if ( ++index == 1 ) /* on windows(tm) index starts at 1 */
    {
        arguments << "interface" << "ip" << "set" << "dns" << "Local Area Connection" << "static" << resolver.toString();
    }
    else
    {
        arguments << "interface" << "ip" << "add" << "dns" << "Local Area Connection" << resolver.toString() << "index="+QString::number(index);
    }
    QProcess* process = new QProcess();
    process->start(program, arguments);
    while (process->waitForFinished(10000))
    {
        loop.processEvents();
    }
    output = process->readAllStandardOutput().trimmed() + "\n";
    rc = process->exitCode();
    delete process;
    return rc;
}
コード例 #12
0
bool DirtyListExecutor::start()
{
    ChangeSetId = "";
    Progress->setValue(++Done);

    qDebug() << QString("OPEN changeset");

    Progress->setLabelText(tr("OPEN changeset"));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);

    QString DataIn(
        "<osm>"
        "<changeset>"
        "<tag k=\"created_by\" v=\"Merkaartor %1 (%2)\"/>"
        "<tag k=\"comment\" v=\"%3\"/>"
        "</changeset>"
        "</osm>");
    DataIn = DataIn.arg(STRINGIFY(VERSION)).arg(QLocale::system().name().split("_")[0]).arg(Utils::encodeAttributes(glbChangeSetComment));
    QString DataOut;
    QString URL = theDownloader->getURLToOpenChangeSet();
    if (sendRequest("PUT",URL,DataIn, DataOut))
    {
        ChangeSetId = DataOut;
        return true;
    }
    return false;
}
コード例 #13
0
ファイル: RenderThread.cpp プロジェクト: Gamaru/yuvtoolkit
void RenderThread::run()
{
	qRegisterMetaType<FramePtr>("FramePtr");
	qRegisterMetaType<FrameList>("FrameList");
	qRegisterMetaType<FrameListPtr>("FrameListPtr");

	WARNING_LOG("Render run start");

	QEventLoop eventLoop;
	while (!m_Exit)
	{
		eventLoop.processEvents();
		Render();
	}

	WARNING_LOG("Render run cleaning up");

	for (int i = 0; i < m_RenderFrames.size(); i++) 
	{
		FramePtr renderFrame = m_RenderFrames.at(i);
		if (renderFrame)
		{
			m_Renderer->Deallocate(renderFrame);
		}
	}
	m_RenderFrames.clear();

	WARNING_LOG("Render run finish");
}
コード例 #14
0
void ClientManage::run(void)
{
    auto o = connect(qApp, &QCoreApplication::aboutToQuit, [&]()
    {
        m_exitByApplication = true;
        this->quit();
    });

    m_start = new ClientStart(this);
    m_isRun = true;

    this->exec();

    delete m_start;
    m_start = NULL;

    for(auto now = m_sockets.begin(); now != m_sockets.end(); now++)
    {
        now.key()->deleteLater();
    }

    if(!m_exitByApplication)
    {
        QEventLoop eventLoop;
        while(eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents));
    }

    disconnect(o);
}
コード例 #15
0
ファイル: DataThread.cpp プロジェクト: h0st/core
void DataThread::run()
{
  qDebug() << "thread started";
  QEventLoop eventLoop;
  QString login = m_settings.value("user").toString();
  QString password = m_settings.value("password").toString();
  if(login.isEmpty())
    login = "******";
  if(password.isEmpty())
    password = "******";

  m_loginQuery = new LoginQuery(login, password, parent());
  connect(m_loginQuery, SIGNAL(connected()), SLOT(onConnected()));
  connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  m_loginQuery->doRequest();
  for(;;)
  {
    if(m_isConnected)
    {
      qDebug() << "connected: auth_token=" << m_loginQuery->getSession()->getUser()->getToken();
      emit(getFeed());
      //ToDo query RSS

    }
    else
    {
      m_loginQuery->doRequest();
    }

    eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents, 1000);
    QThread::msleep(5000);
  }
}
コード例 #16
0
ファイル: vncview.cpp プロジェクト: SmartisanTech/Wrench
void VncView::startQuitting()
{
    kDebug(5011) << "about to quit";

    setStatus(Disconnecting);

    m_quitFlag = true;

    vncThread.stop();

    unpressModifiers();

    // Disconnect all signals so that we don't get any more callbacks from the client thread
    vncThread.disconnect();

    vncThread.quit();

    const bool quitSuccess = vncThread.wait(500);
    if (!quitSuccess) {
        // happens when vncThread wants to call a slot via BlockingQueuedConnection,
        // needs an event loop in this thread so execution continues after 'emit'
        QEventLoop loop;
        if (!loop.processEvents()) {
            kDebug(5011) << "BUG: deadlocked, but no events to deliver?";
        }
        vncThread.wait(500);
    }

    kDebug(5011) << "Quit VNC thread success:" << quitSuccess;

    setStatus(Disconnected);
}
コード例 #17
0
ファイル: QRDUtils.cpp プロジェクト: Nexuapex/renderdoc
void RDDialog::show(QMenu *menu, QPoint pos)
{
  menu->setWindowModality(Qt::ApplicationModal);
  menu->popup(pos);
  QEventLoop loop;
  while(menu->isVisible())
  {
    loop.processEvents(QEventLoop::WaitForMoreEvents);
    QCoreApplication::sendPostedEvents();
  }
}
コード例 #18
0
ファイル: coredbwatch.cpp プロジェクト: KDE/digikam
void CoreDbWatch::doAnyProcessing()
{
#ifdef HAVE_DBUS
    // In a slave we have no event loop.
    // This method is called when a slave begins a new operation
    // (it calls CoreDbAccess::setParameters then).
    // Allow here queued signals to proceed that may be caused by CoreDbWatch signals
    // that were send from within the DBus listener thread (see above).
    QEventLoop loop;
    loop.processEvents();
#endif
}
コード例 #19
0
ファイル: imagedownloader.cpp プロジェクト: ngot/subsurface
void ImageDownloader::load(){
	QUrl url = QUrl::fromUserInput(QString(picture->filename));
	if (url.isValid()) {
		QEventLoop loop;
		QNetworkRequest request(url);
		connect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(saveImage(QNetworkReply *)));
		QNetworkReply *reply = manager.get(request);
		while (reply->isRunning()) {
			loop.processEvents();
			sleep(1);
		}
	}
コード例 #20
0
void RequestHandlerTask::run()
{
  QEventLoop *el = new QEventLoop(NULL);

  PersistentEchoRequestHandler *req = new PersistentEchoRequestHandler(_descriptor);
  connect(req, SIGNAL(done()), el, SLOT(quit()));
  req->handleRequest();

  el->exec();
  el->processEvents();
  delete el;
  delete req;
}
コード例 #21
0
ファイル: QRDUtils.cpp プロジェクト: Nexuapex/renderdoc
int RDDialog::show(QDialog *dialog)
{
  dialog->setWindowModality(Qt::ApplicationModal);
  dialog->show();
  QEventLoop loop;
  while(dialog->isVisible())
  {
    loop.processEvents(QEventLoop::WaitForMoreEvents);
    QCoreApplication::sendPostedEvents();
  }

  return dialog->result();
}
コード例 #22
0
ファイル: davfile.cpp プロジェクト: cnlpete/cargodock
void DavFile::close()
{
    qDebug() << "closing write buffer";
    myWriteBuffer.close();

    // TODO: timeout!
    QEventLoop evLoop;
    qDebug() << Q_FUNC_INFO << myWaitingForDownload << myWaitingForUpload;
    while (myWaitingForDownload || myWaitingForUpload)
    {
        evLoop.processEvents();
    }
    qDebug() << Q_FUNC_INFO << "finished";
}
コード例 #23
0
  void render(std::vector<TRenderer::RenderData> *rds) {
    QMutex mutex;
    mutex.lock();
    m_completed = false;
    m_renderer.startRendering(rds);

    while (!m_completed) {
      QEventLoop loop;
      loop.processEvents();
      QWaitCondition waitCondition;
      waitCondition.wait(&mutex, 100);
    }
    mutex.unlock();
  }
コード例 #24
0
void TActionForkProcess::start()
{
    if (currentActionContext)
        return;

    currentActionContext = this;
    std::cerr << "_accepted" << std::flush;  // send to tfmanager

    QList<THttpRequest> reqs;
    QEventLoop eventLoop;
    httpSocket = new THttpSocket;

    if (!httpSocket->setSocketDescriptor(TActionContext::socketDesc)) {
        emitError(httpSocket->error());
        goto socket_error;
    }
    TActionContext::socketDesc = 0;

    for (;;) {
        reqs = TActionThread::readRequest(httpSocket);
        tSystemDebug("HTTP request count: %d", reqs.count());

        if (reqs.isEmpty()) {
            break;
        }

        for (QMutableListIterator<THttpRequest> it(reqs); it.hasNext(); ) {
            THttpRequest &req = it.next();
            TActionContext::execute(req);

            httpSocket->flush();  // Flush socket
            TActionContext::release();
        }

        if (!httpSocket->waitForReadyRead(5000))
            break;
    }

    closeHttpSocket();  // disconnect

    // For cleanup
    while (eventLoop.processEvents()) {}

    emit finished();
    QCoreApplication::exit(1);

socket_error:
    delete httpSocket;
    httpSocket = 0;
}
コード例 #25
0
/*!
  Enters the main event loop and waits until exit() is called. Returns the
  value that was set to exit() (which is 0 if exit() is called via quit()).
*/
int TWebApplication::exec()
{
    resetSignalNumber();

#ifdef TF_USE_GUI_MODULE
    int ret = QApplication::exec();
#else
    int ret = QCoreApplication::exec();
#endif

    QEventLoop eventLoop;
    while (eventLoop.processEvents()) { }
    return ret;
}
コード例 #26
0
void LLCCEP_debugger::debugCore::continueExecution()
{
	DEBUG_CORE_OK;

	if (gotError) {
		gotError = false;
		::std::cerr << "Got an error, restarting program" << ::std::endl;
		softcore::pc = softcore::reader->getProgramData().main_id;
	}

	auto breakpointReached = [this]() {
		::std::string fname = softcore::reader->getInstructionFile(softcore::pc);
		size_t line = softcore::reader->getInstructionLine(softcore::pc);

		for (auto i = breakpoints.begin(); i < breakpoints.end(); i++) {
			if (i->fname == fname && i->line == line)
				return i;
		}

		return breakpoints.end();
	};

	QEventLoop ev;
	while (running()) {
		auto bp = breakpointReached();
		if (bp != breakpoints.end() && bp->active && !forcedExecution) {
			forcedExecution = true;
			break;
		} else if (bp != breakpoints.end() && bp->active && forcedExecution) {
			forcedExecution = false;
		}

		try {
			softcore::executeNextInstruction();
		} catch (::LLCCEP::runtime_exception &exc) {
			::std::cerr << "Execution was interrupted by an exception:" << ::std::endl
				    << exc.msg() << ::std::endl;
			gotError = true;
			break;
		} catch (...) {
			throw RUNTIME_EXCEPTION(CONSTRUCT_MSG(
				"Got runtime error while program execution"));
		}

		ev.processEvents(QEventLoop::AllEvents, 100);
	}

	DEBUG_CORE_OK;
}
コード例 #27
0
ファイル: algorithm.cpp プロジェクト: AoD314/pat
	FunctionND Algorithm::function(const Point &point)
	{
		*lock = 1;

		emit run_application(point);

		QEventLoop loop;
		while (*lock != 0)
		{
			loop.processEvents();
		}

		function_nd.point = point;
		return function_nd;
	}
コード例 #28
0
Plug_Entity *Doc_plugin_interface::getEnt(const QString& mesage){
    QC_ActionGetEnt* a = new QC_ActionGetEnt(*doc, *gView);
    if (a!=NULL) {
        if (!(mesage.isEmpty()) )
            a->setMesage(mesage);
        gView->killAllActions();
        gView->setCurrentAction(a);
        QEventLoop ev;
        while ( !a->isCompleted())
        {
            ev.processEvents ();
        }
    }
    Plug_Entity *e = reinterpret_cast<Plug_Entity*>(a->getSelected());
    gView->killAllActions();
    return e;
}
コード例 #29
0
bool DirtyListExecutor::stop()
{
    Progress->setValue(++Done);

    qDebug() << QString("CLOSE changeset");

    Progress->setLabelText(tr("CLOSE changeset"));
    QEventLoop L; L.processEvents(QEventLoop::ExcludeUserInputEvents);

    QString URL = theDownloader->getURLToCloseChangeSet(ChangeSetId);
    QString DataIn, DataOut;
    if (sendRequest("PUT",URL,DataIn,DataOut))
    {
        ChangeSetId = "";
        return true;
    }

    return true;
}
コード例 #30
0
bool Doc_plugin_interface::getPoint(QPointF *point, const QString& mesage, QPointF *base){
    bool status = false;
    QC_ActionGetPoint* a = new QC_ActionGetPoint(*doc, *gView);
    if (a!=NULL) {
        if (!(mesage.isEmpty()) ) a->setMesage(mesage);
        gView->killAllActions();
        gView->setCurrentAction(a);
        if (base) a->setBasepoint(base);
        QEventLoop ev;
        while (gView->getCurrentAction() ==a)
        {
            ev.processEvents (QEventLoop::ExcludeSocketNotifiers);
        }
        a->getPoint(point);
        status = true;
//RLZ: delete QC_ActionGetPoint. Investigate how to kill only this action
        gView->killAllActions();
    }
    return status;
}