void tst_QElapsedTimer::validity() { QElapsedTimer t; t.invalidate(); QVERIFY(!t.isValid()); t.start(); QVERIFY(t.isValid()); t.invalidate(); QVERIFY(!t.isValid()); }
void tst_QElapsedTimer::validity() { QElapsedTimer t; QVERIFY(!t.isValid()); // non-POD now, it should always start invalid t.start(); QVERIFY(t.isValid()); t.invalidate(); QVERIFY(!t.isValid()); }
AppModelPrivate() : src(NULL), nam(NULL), ns(NULL), fcProp(NULL), ready(false), useGps(true), nErrors(0), minMsBeforeNewRequest(baseMsBeforeNewRequest) { delayedCityRequestTimer.setSingleShot(true); delayedCityRequestTimer.setInterval(1000); // 1 s requestNewWeatherTimer.setSingleShot(false); requestNewWeatherTimer.setInterval(20*60*1000); // 20 min throttle.invalidate(); }
void QSGDefaultRenderer::render() { #if defined (QML_RUNTIME_TESTING) static bool dumpTree = qApp->arguments().contains(QLatin1String("--dump-tree")); if (dumpTree) { printf("\n\n"); QSGNodeDumper::dump(rootNode()); } #endif #ifdef RENDERER_DEBUG debugTimer.invalidate(); debugTimer.start(); geometryNodesDrawn = 0; materialChanges = 0; #endif glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glFrontFace(isMirrored() ? GL_CW : GL_CCW); glDisable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthMask(true); glDepthFunc(GL_GREATER); #if defined(QT_OPENGL_ES) glClearDepthf(0); #else glClearDepth(0); #endif glDisable(GL_SCISSOR_TEST); glClearColor(m_clear_color.redF(), m_clear_color.greenF(), m_clear_color.blueF(), m_clear_color.alphaF()); #ifdef RENDERER_DEBUG int debugtimeSetup = debugTimer.elapsed(); #endif bindable()->clear(clearMode()); #ifdef RENDERER_DEBUG int debugtimeClear = debugTimer.elapsed(); #endif QRect r = viewportRect(); glViewport(r.x(), deviceRect().bottom() - r.bottom(), r.width(), r.height()); m_current_projection_matrix = projectionMatrix(); m_current_model_view_matrix.setToIdentity(); m_currentClip = 0; glDisable(GL_STENCIL_TEST); m_currentMaterial = 0; m_currentProgram = 0; m_currentMatrix = 0; if (m_rebuild_lists) { m_opaqueNodes.reset(); m_transparentNodes.reset(); m_currentRenderOrder = 1; buildLists(rootNode()); m_rebuild_lists = false; } #ifdef RENDERER_DEBUG int debugtimeLists = debugTimer.elapsed(); #endif if (m_needs_sorting) { if (!m_opaqueNodes.isEmpty()) { qSort(&m_opaqueNodes.first(), &m_opaqueNodes.first() + m_opaqueNodes.size(), m_sort_front_to_back ? nodeLessThanWithRenderOrder : nodeLessThan); } m_needs_sorting = false; } #ifdef RENDERER_DEBUG int debugtimeSorting = debugTimer.elapsed(); #endif m_renderOrderMatrix.setToIdentity(); m_renderOrderMatrix.scale(1, 1, qreal(1) / m_currentRenderOrder); glDisable(GL_BLEND); glDepthMask(true); #ifdef QML_RUNTIME_TESTING if (m_render_opaque_nodes) #endif { #if defined (QML_RUNTIME_TESTING) if (dumpTree) qDebug() << "Opaque Nodes:"; #endif renderNodes(m_opaqueNodes); } #ifdef RENDERER_DEBUG int debugtimeOpaque = debugTimer.elapsed(); int opaqueNodes = geometryNodesDrawn; int opaqueMaterialChanges = materialChanges; #endif glEnable(GL_BLEND); glDepthMask(false); #ifdef QML_RUNTIME_TESTING if (m_render_alpha_nodes) #endif { #if defined (QML_RUNTIME_TESTING) if (dumpTree) qDebug() << "Alpha Nodes:"; #endif renderNodes(m_transparentNodes); } #ifdef RENDERER_DEBUG int debugtimeAlpha = debugTimer.elapsed(); #endif if (m_currentProgram) m_currentProgram->deactivate(); #ifdef RENDERER_DEBUG if (debugTimer.elapsed() > DEBUG_THRESHOLD) { printf(" --- Renderer breakdown:\n" " - setup=%d, clear=%d, building=%d, sorting=%d, opaque=%d, alpha=%d\n" " - material changes: opaque=%d, alpha=%d, total=%d\n" " - geometry ndoes: opaque=%d, alpha=%d, total=%d\n", debugtimeSetup, debugtimeClear - debugtimeSetup, debugtimeLists - debugtimeClear, debugtimeSorting - debugtimeLists, debugtimeOpaque - debugtimeSorting, debugtimeAlpha - debugtimeOpaque, opaqueMaterialChanges, materialChanges - opaqueMaterialChanges, materialChanges, opaqueNodes, geometryNodesDrawn - opaqueNodes, geometryNodesDrawn); } #endif }
double InitializationThread::doInit(const size_t threadCount) { m_bSuccess = false; delay(); //CPU type selection unsigned int cpuSupport = 0; if((m_cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE) && (m_cpuFeatures.features & MUtils::CPUFetaures::FLAG_SSE2) && m_cpuFeatures.intel) { cpuSupport = m_cpuFeatures.x64 ? CPU_TYPE_X64_SSE : CPU_TYPE_X86_SSE; } else { cpuSupport = m_cpuFeatures.x64 ? CPU_TYPE_X64_GEN : CPU_TYPE_X86_GEN; } //Hack to disable x64 on Wine, as x64 binaries won't run under Wine (tested with Wine 1.4 under Ubuntu 12.04 x64) if(cpuSupport & CPU_TYPE_X64_ALL) { if(MUtils::OS::running_on_wine()) { qWarning("Running under Wine on a 64-Bit system. Going to disable all x64 support!\n"); cpuSupport = (cpuSupport == CPU_TYPE_X64_SSE) ? CPU_TYPE_X86_SSE : CPU_TYPE_X86_GEN; } } //Print selected CPU type switch(cpuSupport) { PRINT_CPU_TYPE(CPU_TYPE_X86_GEN); break; PRINT_CPU_TYPE(CPU_TYPE_X86_SSE); break; PRINT_CPU_TYPE(CPU_TYPE_X64_GEN); break; PRINT_CPU_TYPE(CPU_TYPE_X64_SSE); break; default: MUTILS_THROW("CPU support undefined!"); } //Allocate queues QQueue<QString> queueToolName; QQueue<QString> queueChecksum; QQueue<QString> queueVersInfo; QQueue<unsigned int> queueVersions; QQueue<unsigned int> queueCpuTypes; //Init properties for(int i = 0; true; i++) { if(!(g_lamexp_tools[i].pcName || g_lamexp_tools[i].pcHash || g_lamexp_tools[i].uiVersion)) { break; } else if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash && g_lamexp_tools[i].uiVersion) { queueToolName.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcName)); queueChecksum.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcHash)); queueVersInfo.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcVersTag)); queueCpuTypes.enqueue(g_lamexp_tools[i].uiCpuType); queueVersions.enqueue(g_lamexp_tools[i].uiVersion); } else { qFatal("Inconsistent checksum data detected. Take care!"); } } QDir appDir = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); QScopedPointer<QThreadPool> pool(new QThreadPool()); pool->setMaxThreadCount((threadCount > 0) ? threadCount : qBound(2U, cores2threads(m_cpuFeatures.count), EXPECTED_TOOL_COUNT)); /* qWarning("Using %u threads for extraction.", pool->maxThreadCount()); */ LockedFile::selfTest(); ExtractorTask::clearFlags(); //Start the timer QElapsedTimer timeExtractStart; timeExtractStart.start(); //Extract all files while(!(queueToolName.isEmpty() || queueChecksum.isEmpty() || queueVersInfo.isEmpty() || queueCpuTypes.isEmpty() || queueVersions.isEmpty())) { const QString toolName = queueToolName.dequeue(); const QString checksum = queueChecksum.dequeue(); const QString versInfo = queueVersInfo.dequeue(); const unsigned int cpuType = queueCpuTypes.dequeue(); const unsigned int version = queueVersions.dequeue(); const QByteArray toolHash(checksum.toLatin1()); if(toolHash.size() != 96) { qFatal("The checksum for \"%s\" has an invalid size!", MUTILS_UTF8(toolName)); return -1.0; } QResource *resource = new QResource(QString(":/tools/%1").arg(toolName)); if(!(resource->isValid() && resource->data())) { MUTILS_DELETE(resource); qFatal("The resource for \"%s\" could not be found!", MUTILS_UTF8(toolName)); return -1.0; } if(cpuType & cpuSupport) { pool->start(new ExtractorTask(resource, appDir, toolName, toolHash, version, versInfo)); continue; } MUTILS_DELETE(resource); } //Sanity Check if(!(queueToolName.isEmpty() && queueChecksum.isEmpty() && queueVersInfo.isEmpty() && queueCpuTypes.isEmpty() && queueVersions.isEmpty())) { qFatal("Checksum queues *not* empty fater verification completed. Take care!"); } //Wait for extrator threads to finish pool->waitForDone(); //Performance measure const double delayExtract = double(timeExtractStart.elapsed()) / 1000.0; timeExtractStart.invalidate(); //Make sure all files were extracted correctly if(ExtractorTask::getExcept()) { char errorMsg[BUFF_SIZE]; if(ExtractorTask::getErrMsg(errorMsg, BUFF_SIZE)) { qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg); return -1.0; } qFatal("At least one of the required tools could not be initialized!"); return -1.0; } qDebug("All extracted.\n"); //Using any custom tools? if(ExtractorTask::getCustom()) { qWarning("Warning: Using custom tools, you might encounter unexpected problems!\n"); } //Check delay if(delayExtract > g_allowedExtractDelay) { m_slowIndicator = true; qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract); qWarning("Please report performance problems to your anti-virus developer !!!\n"); } else { qDebug("Extracting the tools took %.3f seconds (OK).\n", delayExtract); } //Register all translations initTranslations(); //Look for AAC encoders InitAacEncTask::clearFlags(); for(size_t i = 0; g_lamexp_aacenc[i].toolName; i++) { pool->start(new InitAacEncTask(&(g_lamexp_aacenc[i]))); } pool->waitForDone(); //Make sure initialization finished correctly if(InitAacEncTask::getExcept()) { char errorMsg[BUFF_SIZE]; if(InitAacEncTask::getErrMsg(errorMsg, BUFF_SIZE)) { qFatal("At least one optional component failed to initialize:\n%s", errorMsg); return -1.0; } qFatal("At least one optional component failed to initialize!"); return -1.0; } m_bSuccess = true; delay(); return delayExtract; }