diff options
Diffstat (limited to 'src/plugins/qmltooling')
32 files changed, 348 insertions, 318 deletions
diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp index d20ddf9dc0..e541810330 100644 --- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp +++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp @@ -124,12 +124,9 @@ QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent) Q_ASSERT(4 == sizeof(qint32)); Q_ASSERT(dev); - QObject::connect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::connect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::connect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); + QObject::connect(dev, &QIODevice::readyRead, this, &QPacketProtocol::readyToRead); + QObject::connect(dev, &QIODevice::aboutToClose, this, &QPacketProtocol::aboutToClose); + QObject::connect(dev, &QIODevice::bytesWritten, this, &QPacketProtocol::bytesWritten); } /*! @@ -247,12 +244,9 @@ void QPacketProtocol::readyToRead() // Check sizing constraints if (d->inProgressSize > MAX_PACKET_SIZE) { - QObject::disconnect(d->dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::disconnect(d->dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::disconnect(d->dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); + disconnect(d->dev, &QIODevice::readyRead, this, &QPacketProtocol::readyToRead); + disconnect(d->dev, &QIODevice::aboutToClose, this, &QPacketProtocol::aboutToClose); + disconnect(d->dev, &QIODevice::bytesWritten, this, &QPacketProtocol::bytesWritten); d->dev = 0; emit invalidPacket(); return; diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h index 8f95a081e9..7fd722f17f 100644 --- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h +++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h @@ -74,7 +74,7 @@ Q_SIGNALS: void readyRead(); void invalidPacket(); -private Q_SLOTS: +private: void aboutToClose(); void bytesWritten(qint64 bytes); void readyToRead(); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp index 31873f7915..b0f59717ac 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp @@ -70,7 +70,7 @@ void QDebugMessageServiceImpl::sendDebugMessage(QtMsgType type, //We just eavesdrop and forward the messages to a port //only if a client is connected to it. QQmlDebugPacket ws; - ws << QByteArray("MESSAGE") << type << buf.toUtf8(); + ws << QByteArray("MESSAGE") << int(type) << buf.toUtf8(); ws << QByteArray(ctxt.file) << ctxt.line << QByteArray(ctxt.function); ws << QByteArray(ctxt.category) << timer.nsecsElapsed(); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index ff4e30835d..f72b8a51f9 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -63,8 +63,12 @@ QT_BEGIN_NAMESPACE QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) : QQmlEngineDebugService(2, parent), m_watch(new QQmlWatcher(this)), m_statesDelegate(0) { - QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), - this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); + connect(m_watch, &QQmlWatcher::propertyChanged, + this, &QQmlEngineDebugServiceImpl::propertyChanged); + + // Move the message into the correct thread for processing + connect(this, &QQmlEngineDebugServiceImpl::scheduleMessage, + this, &QQmlEngineDebugServiceImpl::processMessage, Qt::QueuedConnection); } QQmlEngineDebugServiceImpl::~QQmlEngineDebugServiceImpl() @@ -420,7 +424,7 @@ QQmlEngineDebugServiceImpl::objectData(QObject *object) void QQmlEngineDebugServiceImpl::messageReceived(const QByteArray &message) { - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); + emit scheduleMessage(message); } /*! @@ -656,7 +660,7 @@ bool QQmlEngineDebugServiceImpl::setBinding(int objectId, filename, line, column); QQmlPropertyPrivate::takeSignalExpression(property, qmlExpression); } else if (property.isProperty()) { - QQmlBinding *binding = new QQmlBinding(expression.toString(), object, QQmlContextData::get(context), filename, line, column); + QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), filename, line, column); binding->setTarget(property); QQmlPropertyPrivate::setBinding(binding); binding->update(); @@ -749,7 +753,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth if (!prop || !prop->isVMEFunction()) return false; - QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); + QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex()); QList<QByteArray> paramNames = metaMethod.parameterNames(); QString paramStr; @@ -758,19 +762,22 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth paramStr.append(QString::fromUtf8(paramNames.at(ii))); } - QString jsfunction = QLatin1String("(function ") + method + QLatin1Char('(') + paramStr + - QLatin1String(") {"); - jsfunction += body; - jsfunction += QLatin1String("\n})"); + const QString jsfunction = QLatin1String("(function ") + method + QLatin1Char('(') + paramStr + + QLatin1String(") {") + body + QLatin1String("\n})"); QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(object); Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this - int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex); QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine(object)->handle()); QV4::Scope scope(v4); + + int lineNumber = 0; + QV4::ScopedFunctionObject oldMethod(scope, vmeMetaObject->vmeMethod(prop->coreIndex())); + if (oldMethod && oldMethod->d()->function) { + lineNumber = oldMethod->d()->function->compiledFunction->location.line; + } QV4::ScopedValue v(scope, QQmlJavaScriptExpression::evalFunction(contextData, object, jsfunction, contextData->urlString(), lineNumber)); - vmeMetaObject->setVmeMethod(prop->coreIndex, v); + vmeMetaObject->setVmeMethod(prop->coreIndex(), v); return true; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h index cb75a63850..2e40eb4de8 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.h @@ -101,16 +101,18 @@ public: void setStatesDelegate(QQmlDebugStatesDelegate *) Q_DECL_OVERRIDE; +signals: + void scheduleMessage(const QByteArray &); + protected: virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; -private Q_SLOTS: - void processMessage(const QByteArray &msg); - void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); - private: friend class QQmlDebuggerServiceFactory; + void processMessage(const QByteArray &msg); + void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); + void prepareDeferredObjects(QObject *); void buildObjectList(QDataStream &, QQmlContext *, const QList<QPointer<QObject> > &instances); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index e3b2bc0870..5b96163b48 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -143,15 +143,15 @@ public: void BreakPointHandler::handleSetBreakpoint(QJsonObject *response, const QJsonObject &arguments) { TRACE_PROTOCOL("SET BREAKPOINT" << arguments); - QString type = arguments.value(QStringLiteral("type")).toString(); + QString type = arguments.value(QLatin1String("type")).toString(); - QString fileName = arguments.value(QStringLiteral("file")).toString(); + QString fileName = arguments.value(QLatin1String("file")).toString(); if (fileName.isEmpty()) { setError(response, QStringLiteral("breakpoint has no file name")); return; } - int line = arguments.value(QStringLiteral("line")).toInt(-1); + int line = arguments.value(QLatin1String("line")).toInt(-1); if (line < 0) { setError(response, QStringLiteral("breakpoint has an invalid line number")); return; @@ -161,9 +161,9 @@ void BreakPointHandler::handleSetBreakpoint(QJsonObject *response, const QJsonOb bp.id = m_lastBreakpoint++; bp.fileName = fileName.mid(fileName.lastIndexOf('/') + 1); bp.lineNumber = line; - bp.enabled = arguments.value(QStringLiteral("enabled")).toBool(true); - bp.condition = arguments.value(QStringLiteral("condition")).toString(); - bp.ignoreCount = arguments.value(QStringLiteral("ignorecount")).toInt(); + bp.enabled = arguments.value(QLatin1String("enabled")).toBool(true); + bp.condition = arguments.value(QLatin1String("condition")).toString(); + bp.ignoreCount = arguments.value(QLatin1String("ignorecount")).toInt(); m_breakPoints.append(bp); m_haveBreakPoints = true; @@ -174,7 +174,7 @@ void BreakPointHandler::handleSetBreakpoint(QJsonObject *response, const QJsonOb void BreakPointHandler::handleRemoveBreakpoint(QJsonObject *response, const QJsonObject &arguments) { - int id = arguments.value(QStringLiteral("id")).toInt(); + int id = arguments.value(QLatin1String("id")).toInt(); removeBreakPoint(id); response->insert(QStringLiteral("id"), id); } @@ -208,7 +208,7 @@ private: void handleDebuggerDeleted(QObject *debugger); - QV4::ReturnedValue evaluateExpression(QV4::Scope &scope, const QString &expression); + void evaluateExpression(QV4::Scope &scope, const QString &expression); bool checkCondition(const QString &expression); QStringList breakOnSignals; @@ -241,12 +241,11 @@ private: bool NativeDebugger::checkCondition(const QString &expression) { QV4::Scope scope(m_engine); - QV4::ReturnedValue result = evaluateExpression(scope, expression); - QV4::ScopedValue val(scope, result); - return val->booleanValue(); + evaluateExpression(scope, expression); + return scope.result.booleanValue(); } -QV4::ReturnedValue NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expression) +void NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expression) { m_runningJob = true; @@ -261,12 +260,10 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(QV4::Scope &scope, const Q // That is a side-effect of inheritContext. script.inheritContext = true; script.parse(); - QV4::ScopedValue result(scope); if (!m_engine->hasException) - result = script.run(); + scope.result = script.run(); m_runningJob = false; - return result->asReturnedValue(); } NativeDebugger::NativeDebugger(QQmlNativeDebugServiceImpl *service, QV4::ExecutionEngine *engine) @@ -301,19 +298,19 @@ void NativeDebugger::signalEmitted(const QString &signal) void NativeDebugger::handleCommand(QJsonObject *response, const QString &cmd, const QJsonObject &arguments) { - if (cmd == QStringLiteral("backtrace")) + if (cmd == QLatin1String("backtrace")) handleBacktrace(response, arguments); - else if (cmd == QStringLiteral("variables")) + else if (cmd == QLatin1String("variables")) handleVariables(response, arguments); - else if (cmd == QStringLiteral("expressions")) + else if (cmd == QLatin1String("expressions")) handleExpressions(response, arguments); - else if (cmd == QStringLiteral("stepin")) + else if (cmd == QLatin1String("stepin")) handleContinue(response, StepIn); - else if (cmd == QStringLiteral("stepout")) + else if (cmd == QLatin1String("stepout")) handleContinue(response, StepOut); - else if (cmd == QStringLiteral("stepover")) + else if (cmd == QLatin1String("stepover")) handleContinue(response, StepOver); - else if (cmd == QStringLiteral("continue")) + else if (cmd == QLatin1String("continue")) handleContinue(response, NotStepping); } @@ -334,7 +331,7 @@ static void decodeContext(const QString &context, QV4::ExecutionContext **execut void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &arguments) { - int limit = arguments.value(QStringLiteral("limit")).toInt(0); + int limit = arguments.value(QLatin1String("limit")).toInt(0); QJsonArray frameArray; QV4::ExecutionContext *executionContext = m_engine->currentContext; @@ -374,7 +371,7 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri dict.insert(QStringLiteral("iname"), iname); dict.insert(QStringLiteral("name"), nonEmptyName); - QV4::ScopedValue typeString(scope, QV4::Runtime::typeofValue(m_engine, value)); + QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(m_engine, value)); dict.insert(QStringLiteral("type"), typeString->toQStringNoThrow()); switch (value.type()) { @@ -463,7 +460,7 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a { TRACE_PROTOCOL("Build variables"); QV4::ExecutionContext *executionContext = 0; - decodeContext(arguments.value(QStringLiteral("context")).toString(), &executionContext); + decodeContext(arguments.value(QLatin1String("context")).toString(), &executionContext); if (!executionContext) { setError(response, QStringLiteral("No execution context passed")); return; @@ -478,7 +475,7 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a TRACE_PROTOCOL("Engine: " << engine); Collector collector(engine); - QJsonArray expanded = arguments.value(QStringLiteral("expanded")).toArray(); + QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray(); foreach (const QJsonValue &ex, expanded) collector.m_expanded.append(ex.toString()); TRACE_PROTOCOL("Expanded: " << collector.m_expanded); @@ -515,7 +512,7 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject { TRACE_PROTOCOL("Evaluate expressions"); QV4::ExecutionContext *executionContext = 0; - decodeContext(arguments.value(QStringLiteral("context")).toString(), &executionContext); + decodeContext(arguments.value(QLatin1String("context")).toString(), &executionContext); if (!executionContext) { setError(response, QStringLiteral("No execution context passed")); return; @@ -530,7 +527,7 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject TRACE_PROTOCOL("Engines: " << engine << m_engine); Collector collector(engine); - QJsonArray expanded = arguments.value(QStringLiteral("expanded")).toArray(); + QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray(); foreach (const QJsonValue &ex, expanded) collector.m_expanded.append(ex.toString()); TRACE_PROTOCOL("Expanded: " << collector.m_expanded); @@ -538,15 +535,15 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject QJsonArray output; QV4::Scope scope(engine); - QJsonArray expressions = arguments.value(QStringLiteral("expressions")).toArray(); + QJsonArray expressions = arguments.value(QLatin1String("expressions")).toArray(); foreach (const QJsonValue &expr, expressions) { - QString expression = expr.toObject().value(QStringLiteral("expression")).toString(); - QString name = expr.toObject().value(QStringLiteral("name")).toString(); + QString expression = expr.toObject().value(QLatin1String("expression")).toString(); + QString name = expr.toObject().value(QLatin1String("name")).toString(); TRACE_PROTOCOL("Evaluate expression: " << expression); m_runningJob = true; - QV4::ReturnedValue eval = evaluateExpression(scope, expression); - QV4::ScopedValue result(scope, eval); + evaluateExpression(scope, expression); + QV4::ScopedValue result(scope, scope.result); m_runningJob = false; if (result->isUndefined()) { @@ -764,7 +761,7 @@ void QQmlNativeDebugServiceImpl::stateAboutToBeChanged(QQmlDebugService::State s if (state == Enabled) { foreach (NativeDebugger *debugger, m_debuggers) { QV4::ExecutionEngine *engine = debugger->engine(); - if (!engine->debugger) + if (!engine->debugger()) engine->setDebugger(debugger); } } @@ -776,14 +773,14 @@ void QQmlNativeDebugServiceImpl::messageReceived(const QByteArray &message) TRACE_PROTOCOL("Native message received: " << message); QJsonObject request = QJsonDocument::fromJson(message).object(); QJsonObject response; - QJsonObject arguments = request.value(QStringLiteral("arguments")).toObject(); - QString cmd = request.value(QStringLiteral("command")).toString(); + QJsonObject arguments = request.value(QLatin1String("arguments")).toObject(); + QString cmd = request.value(QLatin1String("command")).toString(); - if (cmd == QStringLiteral("setbreakpoint")) { + if (cmd == QLatin1String("setbreakpoint")) { m_breakHandler->handleSetBreakpoint(&response, arguments); - } else if (cmd == QStringLiteral("removebreakpoint")) { + } else if (cmd == QLatin1String("removebreakpoint")) { m_breakHandler->handleRemoveBreakpoint(&response, arguments); - } else if (cmd == QStringLiteral("echo")) { + } else if (cmd == QLatin1String("echo")) { response.insert(QStringLiteral("result"), arguments); } else { foreach (NativeDebugger *debugger, m_debuggers) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp index 392080dd51..1214212727 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp @@ -69,7 +69,7 @@ public: QQmlWatcher *parent = 0); public slots: - void notifyValueChanged(); + void notifyValueChanged(); // Needs to be a slot because of QQmlPropertyPrivate::connect() private: friend class QQmlWatcher; @@ -88,7 +88,8 @@ QQmlWatchProxy::QQmlWatchProxy(int id, QQmlWatcher *parent) : QObject(parent), m_id(id), m_watch(parent), m_object(0), m_debugId(debugId), m_expr(exp) { - QObject::connect(m_expr, SIGNAL(valueChanged()), this, SLOT(notifyValueChanged())); + QObject::connect(m_expr, &QQmlExpression::valueChanged, + this, &QQmlWatchProxy::notifyValueChanged); } QQmlWatchProxy::QQmlWatchProxy(int id, diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 96f60b24bb..b2db23d78c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -134,7 +134,7 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution QJsonObject &dict) { QV4::Scope scope(engine); - QV4::ScopedValue typeString(scope, QV4::Runtime::typeofValue(engine, value)); + QV4::ScopedValue typeString(scope, QV4::Runtime::method_typeofValue(engine, value)); dict.insert(QStringLiteral("type"), typeString->toQStringNoThrow()); const QLatin1String valueKey("value"); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 53f2eab5ff..44810dd4cb 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -79,6 +79,8 @@ QV4Debugger::QV4Debugger(QV4::ExecutionEngine *engine) static int pauseReasonId = qRegisterMetaType<QV4Debugger::PauseReason>(); Q_UNUSED(debuggerId); Q_UNUSED(pauseReasonId); + connect(this, &QV4Debugger::scheduleJob, + this, &QV4Debugger::runJobUnpaused, Qt::QueuedConnection); } QV4::ExecutionEngine *QV4Debugger::engine() const @@ -320,7 +322,7 @@ void QV4Debugger::runInEngine_havingLock(QV4DebugJob *job) if (state() == Paused) m_runningCondition.wakeAll(); else - QMetaObject::invokeMethod(this, "runJobUnpaused", Qt::QueuedConnection); + emit scheduleJob(); m_jobIsRunning.wait(&m_lock); m_runningJob = 0; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h index 3a5b6080cb..cd412e573d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h @@ -140,15 +140,14 @@ public: signals: void debuggerPaused(QV4Debugger *self, QV4Debugger::PauseReason reason); - -private slots: - void runJobUnpaused(); + void scheduleJob(); private: // requires lock to be held void pauseAndWait(PauseReason reason); bool reallyHitTheBreakPoint(const QString &filename, int linenr); void runInEngine_havingLock(QV4DebugJob *job); + void runJobUnpaused(); QV4::ExecutionEngine *m_engine; QV4::PersistentValue m_currentContext; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index a90d03b010..756b6b28be 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -114,7 +114,7 @@ void QV4DebuggerAgent::addDebugger(QV4Debugger *debugger) debugger->setBreakOnThrow(m_breakOnThrow); - foreach (const BreakPoint &breakPoint, m_breakPoints.values()) + for (const BreakPoint &breakPoint : qAsConst(m_breakPoints)) if (breakPoint.enabled) debugger->addBreakPoint(breakPoint.fileName, breakPoint.lineNr, breakPoint.condition); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.h index 1c7eb50ac7..39ac4d4dcb 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.h @@ -72,7 +72,6 @@ public: void setBreakOnThrow(bool onoff); void clearAllPauseRequests(); -public slots: void debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseReason reason); void handleDebuggerDeleted(QObject *debugger); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index 5ee9e5e9e9..00c5c1ad77 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -90,7 +90,7 @@ public: TRACE_PROTOCOL(qDebug() << "handling command" << command() << "..."); req = request; - seq = req.value(QStringLiteral("seq")); + seq = req.value(QLatin1String("seq")); debugService = s; handleRequest(); @@ -128,7 +128,7 @@ protected: void createErrorResponse(const QString &msg) { - QJsonValue command = req.value(QStringLiteral("command")); + QJsonValue command = req.value(QLatin1String("command")); response.insert(QStringLiteral("command"), command); addRequestSequence(); addSuccess(false); @@ -154,9 +154,9 @@ public: virtual void handleRequest() { - QString msg = QStringLiteral("unimplemented command \""); - msg += req.value(QStringLiteral("command")).toString(); - msg += QLatin1Char('"'); + QString msg = QLatin1String("unimplemented command \"") + + req.value(QLatin1String("command")).toString() + + QLatin1Char('"'); createErrorResponse(msg); } }; @@ -189,23 +189,23 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject args = req.value(QStringLiteral("arguments")).toObject(); + QJsonObject args = req.value(QLatin1String("arguments")).toObject(); if (args.isEmpty()) return; - QString type = args.value(QStringLiteral("type")).toString(); - if (type != QStringLiteral("scriptRegExp")) { + QString type = args.value(QLatin1String("type")).toString(); + if (type != QLatin1String("scriptRegExp")) { createErrorResponse(QStringLiteral("breakpoint type \"%1\" is not implemented").arg(type)); return; } - QString fileName = args.value(QStringLiteral("target")).toString(); + QString fileName = args.value(QLatin1String("target")).toString(); if (fileName.isEmpty()) { createErrorResponse(QStringLiteral("breakpoint has no file name")); return; } - int line = args.value(QStringLiteral("line")).toInt(-1); + int line = args.value(QLatin1String("line")).toInt(-1); if (line < 0) { createErrorResponse(QStringLiteral("breakpoint has an invalid line number")); return; @@ -240,11 +240,11 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject args = req.value(QStringLiteral("arguments")).toObject(); + QJsonObject args = req.value(QLatin1String("arguments")).toObject(); if (args.isEmpty()) return; - int id = args.value(QStringLiteral("breakpoint")).toInt(-1); + int id = args.value(QLatin1String("breakpoint")).toInt(-1); if (id < 0) { createErrorResponse(QStringLiteral("breakpoint has an invalid number")); return; @@ -274,9 +274,9 @@ public: { // decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - int fromFrame = arguments.value(QStringLiteral("fromFrame")).toInt(0); - int toFrame = arguments.value(QStringLiteral("toFrame")).toInt(fromFrame + 10); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + int fromFrame = arguments.value(QLatin1String("fromFrame")).toInt(0); + int toFrame = arguments.value(QLatin1String("toFrame")).toInt(fromFrame + 10); // no idea what the bottom property is for, so we'll ignore it. QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); @@ -306,8 +306,8 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - const int frameNr = arguments.value(QStringLiteral("number")).toInt( + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + const int frameNr = arguments.value(QLatin1String("number")).toInt( debugService->selectedFrame()); QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); @@ -348,10 +348,10 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - const int frameNr = arguments.value(QStringLiteral("frameNumber")).toInt( + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + const int frameNr = arguments.value(QLatin1String("frameNumber")).toInt( debugService->selectedFrame()); - const int scopeNr = arguments.value(QStringLiteral("number")).toInt(0); + const int scopeNr = arguments.value(QLatin1String("number")).toInt(0); QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); if (!debugger) { @@ -393,8 +393,8 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - QJsonArray handles = arguments.value(QStringLiteral("handles")).toArray(); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + QJsonArray handles = arguments.value(QLatin1String("handles")).toArray(); QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); if (!debugger) { @@ -433,7 +433,7 @@ public: virtual void handleRequest() { // decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); if (!debugger) { @@ -445,17 +445,17 @@ public: if (arguments.empty()) { debugger->resume(QV4Debugger::FullThrottle); } else { - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - QString stepAction = arguments.value(QStringLiteral("stepaction")).toString(); - const int stepcount = arguments.value(QStringLiteral("stepcount")).toInt(1); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + QString stepAction = arguments.value(QLatin1String("stepaction")).toString(); + const int stepcount = arguments.value(QLatin1String("stepcount")).toInt(1); if (stepcount != 1) qWarning() << "Step count other than 1 is not supported."; - if (stepAction == QStringLiteral("in")) { + if (stepAction == QLatin1String("in")) { debugger->resume(QV4Debugger::StepIn); - } else if (stepAction == QStringLiteral("out")) { + } else if (stepAction == QLatin1String("out")) { debugger->resume(QV4Debugger::StepOut); - } else if (stepAction == QStringLiteral("next")) { + } else if (stepAction == QLatin1String("next")) { debugger->resume(QV4Debugger::StepOver); } else { createErrorResponse(QStringLiteral("continue command has invalid stepaction")); @@ -499,13 +499,13 @@ public: bool wasEnabled = debugService->debuggerAgent.breakOnThrow(); //decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - QString type = arguments.value(QStringLiteral("type")).toString(); - bool enabled = arguments.value(QStringLiteral("number")).toBool(!wasEnabled); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + QString type = arguments.value(QLatin1String("type")).toString(); + bool enabled = arguments.value(QLatin1String("number")).toBool(!wasEnabled); - if (type == QStringLiteral("all")) { + if (type == QLatin1String("all")) { // that's fine - } else if (type == QStringLiteral("uncaught")) { + } else if (type == QLatin1String("uncaught")) { createErrorResponse(QStringLiteral("breaking only on uncaught exceptions is not supported yet")); return; } else { @@ -537,8 +537,8 @@ public: virtual void handleRequest() { //decypher the payload: - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - int types = arguments.value(QStringLiteral("types")).toInt(-1); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + int types = arguments.value(QLatin1String("types")).toInt(-1); if (types < 0 || types > 7) { createErrorResponse(QStringLiteral("invalid types value in scripts command")); return; @@ -608,8 +608,8 @@ public: virtual void handleRequest() { - QJsonObject arguments = req.value(QStringLiteral("arguments")).toObject(); - QString expression = arguments.value(QStringLiteral("expression")).toString(); + QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); + QString expression = arguments.value(QLatin1String("expression")).toString(); int frame = -1; QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); @@ -624,7 +624,7 @@ public: } debugger = debuggers.first(); } else { - frame = arguments.value(QStringLiteral("frame")).toInt(0); + frame = arguments.value(QLatin1String("frame")).toInt(0); } ExpressionEvalJob job(debugger->engine(), frame, expression, debugger->collector()); @@ -706,7 +706,7 @@ void QV4DebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine) if (engine){ const QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); if (ee) { - QV4Debugger *debugger = qobject_cast<QV4Debugger *>(ee->debugger); + QV4Debugger *debugger = qobject_cast<QV4Debugger *>(ee->debugger()); if (debugger) debuggerAgent.removeDebugger(debugger); } @@ -720,7 +720,7 @@ void QV4DebugServiceImpl::stateAboutToBeChanged(State state) if (state == Enabled) { foreach (QV4Debugger *debugger, debuggerAgent.debuggers()) { QV4::ExecutionEngine *ee = debugger->engine(); - if (!ee->debugger) + if (!ee->debugger()) ee->setDebugger(debugger); } } @@ -802,9 +802,9 @@ void QV4DebugServiceImpl::handleV8Request(const QByteArray &payload) QJsonDocument request = QJsonDocument::fromJson(payload); QJsonObject o = request.object(); - QJsonValue type = o.value(QStringLiteral("type")); - if (type.toString() == QStringLiteral("request")) { - QJsonValue command = o.value(QStringLiteral("command")); + QJsonValue type = o.value(QLatin1String("type")); + if (type.toString() == QLatin1String("request")) { + QJsonValue command = o.value(QLatin1String("command")); V8CommandHandler *h = v8CommandHandler(command.toString()); if (h) h->handle(o, this); diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp index 2150b68f32..107d54c626 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp @@ -148,10 +148,6 @@ public: m_component.setData(qml, filename); } -signals: - void result(int requestId, bool success); - -public slots: void tryCreateObject(QQmlComponent::Status status) { switch (status) { @@ -171,7 +167,7 @@ public slots: else emit result(m_requestId, false); } - delete this; + deleteLater(); // The component might send more signals return; } default: @@ -179,6 +175,9 @@ public slots: } } +signals: + void result(int requestId, bool success); + private: QQmlComponent m_component; int m_requestId; diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h index 7bbe6d6aa2..338eee14c3 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h @@ -72,10 +72,8 @@ public: signals: void messageToClient(const QString &name, const QByteArray &data); -private slots: - void sendResult(int requestId, bool success); - private: + void sendResult(int requestId, bool success); void sendCurrentObjects(const QList<QObject *> &objects); void removeFromSelectedItems(QObject *object); QString titleForItem(QQuickItem *item) const; diff --git a/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp b/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp index 26eb0f8ed8..88a6ea6b6d 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp @@ -72,24 +72,22 @@ void Highlight::setItem(QQuickItem *item) m_item->disconnect(this); if (item) { - connect(item, SIGNAL(xChanged()), SLOT(adjust())); - connect(item, SIGNAL(yChanged()), SLOT(adjust())); - connect(item, SIGNAL(widthChanged()), SLOT(adjust())); - connect(item, SIGNAL(heightChanged()), SLOT(adjust())); - connect(item, SIGNAL(rotationChanged()), SLOT(adjust())); - connect(item, SIGNAL(transformOriginChanged(TransformOrigin)), - SLOT(adjust())); + connect(item, &QQuickItem::xChanged, this, &Highlight::adjust); + connect(item, &QQuickItem::yChanged, this, &Highlight::adjust); + connect(item, &QQuickItem::widthChanged, this, &Highlight::adjust); + connect(item, &QQuickItem::heightChanged, this, &Highlight::adjust); + connect(item, &QQuickItem::rotationChanged, this, &Highlight::adjust); + connect(item, &QQuickItem::transformOriginChanged, this, &Highlight::adjust); } QQuickWindow *view = item->window(); QQuickItem * contentItem = view->contentItem(); if (contentItem) { - connect(contentItem, SIGNAL(xChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(yChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(widthChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(heightChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(rotationChanged()), SLOT(adjust())); - connect(contentItem, SIGNAL(transformOriginChanged(TransformOrigin)), - SLOT(adjust())); + connect(contentItem, &QQuickItem::xChanged, this, &Highlight::adjust); + connect(contentItem, &QQuickItem::yChanged, this, &Highlight::adjust); + connect(contentItem, &QQuickItem::widthChanged, this, &Highlight::adjust); + connect(contentItem, &QQuickItem::heightChanged, this, &Highlight::adjust); + connect(contentItem, &QQuickItem::rotationChanged, this, &Highlight::adjust); + connect(contentItem, &QQuickItem::transformOriginChanged, this, &Highlight::adjust); } m_item = item; setContentsSize(view->size()); diff --git a/src/plugins/qmltooling/qmldbg_inspector/highlight.h b/src/plugins/qmltooling/qmldbg_inspector/highlight.h index 4a85cb4d50..2bf4fc1ad5 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/highlight.h +++ b/src/plugins/qmltooling/qmldbg_inspector/highlight.h @@ -65,8 +65,6 @@ protected: private: void initRenderDetails(); - -private slots: void adjust(); private: @@ -86,13 +84,12 @@ public: void paint(QPainter *painter); void showName(const QPointF &displayPoint); -private slots: - void disableNameDisplay(); - private: QPointF m_displayPoint; QString m_name; bool m_nameDisplayActive; + + void disableNameDisplay(); }; /** diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp index 48a3f656b0..ab1aeebf64 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp @@ -55,23 +55,27 @@ public: void setParentWindow(QQuickWindow *window, QWindow *parent) Q_DECL_OVERRIDE; void removeWindow(QQuickWindow *window) Q_DECL_OVERRIDE; +signals: + void scheduleMessage(const QByteArray &message); + protected: virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; -private slots: - void messageFromClient(const QByteArray &message); - private: friend class QQmlInspectorServiceFactory; QmlJSDebugger::GlobalInspector *checkInspector(); QmlJSDebugger::GlobalInspector *m_globalInspector; QHash<QQuickWindow *, QWindow *> m_waitingWindows; + + void messageFromClient(const QByteArray &message); }; QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(QObject *parent): QQmlInspectorService(1, parent), m_globalInspector(0) { + connect(this, &QQmlInspectorServiceImpl::scheduleMessage, + this, &QQmlInspectorServiceImpl::messageFromClient, Qt::QueuedConnection); } QmlJSDebugger::GlobalInspector *QQmlInspectorServiceImpl::checkInspector() @@ -122,8 +126,8 @@ void QQmlInspectorServiceImpl::setParentWindow(QQuickWindow *window, QWindow *pa void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message) { - QMetaObject::invokeMethod(this, "messageFromClient", Qt::QueuedConnection, - Q_ARG(QByteArray, message)); + // Move the message to the right thread via queued signal + emit scheduleMessage(message); } void QQmlInspectorServiceImpl::messageFromClient(const QByteArray &message) diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp index 01c24f2395..64b26bdd0d 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp @@ -65,10 +65,8 @@ public: void waitForConnection(); void flush(); -private slots: - void connectionEstablished(); - private: + void connectionEstablished(); bool connectToServer(); bool m_block; @@ -135,7 +133,8 @@ bool QLocalClientConnection::connectToServer() { m_socket = new QLocalSocket; m_socket->setParent(this); - QObject::connect(m_socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); + QObject::connect(m_socket, &QLocalSocket::connected, + this, &QLocalClientConnection::connectionEstablished); m_socket->connectToServer(m_filename); qDebug("QML Debugger: Connecting to socket %s...", m_filename.toLatin1().constData()); return true; diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h index 03b5b5eb1e..1184925e53 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h @@ -63,11 +63,9 @@ public: bool open(const QVariantHash &configuration) Q_DECL_OVERRIDE; static void setDataStreamVersion(int version); -private slots: +private: void sendMessage(const QString &name, const QByteArray &message); void sendMessages(const QString &name, const QList<QByteArray> &messages); - -private: void announceObjectAvailability(const QString &objectType, QObject *object, bool available); QVector<QQmlDebugService *> m_services; diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp index a193ddea0b..90e817e2fc 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp @@ -48,69 +48,86 @@ QQmlProfilerAdapter::QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEngin next(0) { setService(service); - engine->enableProfiler(); - connect(this, SIGNAL(profilingEnabled(quint64)), engine->profiler, SLOT(startProfiling(quint64))); - connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)), - engine->profiler, SLOT(startProfiling(quint64)), Qt::DirectConnection); - connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling())); - connect(this, SIGNAL(profilingDisabledWhileWaiting()), - engine->profiler, SLOT(stopProfiling()), Qt::DirectConnection); - connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData())); - connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)), - engine->profiler, SLOT(setTimer(QElapsedTimer))); - connect(engine->profiler, - SIGNAL(dataReady(QVector<QQmlProfilerData>,QQmlProfiler::LocationHash)), - this, - SLOT(receiveData(QVector<QQmlProfilerData>,QQmlProfiler::LocationHash))); + engine->profiler = new QQmlProfiler; + connect(this, &QQmlProfilerAdapter::profilingEnabled, + engine->profiler, &QQmlProfiler::startProfiling); + connect(this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting, + engine->profiler, &QQmlProfiler::startProfiling, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabled, + engine->profiler, &QQmlProfiler::stopProfiling); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting, + engine->profiler, &QQmlProfiler::stopProfiling, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::dataRequested, + engine->profiler, &QQmlProfiler::reportData); + connect(this, &QQmlAbstractProfilerAdapter::referenceTimeKnown, + engine->profiler, &QQmlProfiler::setTimer); + connect(engine->profiler, &QQmlProfiler::dataReady, + this, &QQmlProfilerAdapter::receiveData); } // convert to QByteArrays that can be sent to the debug client // use of QDataStream can skew results // (see tst_qqmldebugtrace::trace() benchmark) static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d, - const QQmlProfiler::LocationHash &locations, - QList<QByteArray> &messages) + QQmlProfiler::LocationHash &locations, + QList<QByteArray> &messages, + bool trackLocations) { QQmlDebugPacket ds; Q_ASSERT_X((d.messageType & (1 << 31)) == 0, Q_FUNC_INFO, "You can use at most 31 message types."); for (quint32 decodedMessageType = 0; (d.messageType >> decodedMessageType) != 0; ++decodedMessageType) { - if ((d.messageType & (1 << decodedMessageType)) == 0) - continue; - - //### using QDataStream is relatively expensive - ds << d.time << decodedMessageType << static_cast<quint32>(d.detailType); - - QQmlProfiler::Location l = locations.value(d.locationId); + if (decodedMessageType == QQmlProfilerDefinitions::RangeData + || (d.messageType & (1 << decodedMessageType)) == 0) { + continue; // RangeData is sent together with RangeLocation + } - switch (decodedMessageType) { - case QQmlProfilerDefinitions::RangeStart: - case QQmlProfilerDefinitions::RangeEnd: - break; - case QQmlProfilerDefinitions::RangeData: - ds << (l.location.sourceFile.isEmpty() ? l.url.toString() : l.location.sourceFile); - break; - case QQmlProfilerDefinitions::RangeLocation: - ds << (l.url.isEmpty() ? l.location.sourceFile : l.url.toString()) - << static_cast<qint32>(l.location.line) << static_cast<qint32>(l.location.column); - break; - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type."); - break; + if (decodedMessageType == QQmlProfilerDefinitions::RangeEnd + || decodedMessageType == QQmlProfilerDefinitions::RangeStart) { + ds << d.time << decodedMessageType << static_cast<quint32>(d.detailType); + if (trackLocations && d.locationId != 0) + ds << static_cast<qint64>(d.locationId); + } else { + auto i = locations.find(d.locationId); + if (i != locations.end()) { + ds << d.time << decodedMessageType << static_cast<quint32>(d.detailType); + ds << (i->url.isEmpty() ? i->location.sourceFile : i->url.toString()) + << static_cast<qint32>(i->location.line) + << static_cast<qint32>(i->location.column); + if (d.messageType & (1 << QQmlProfilerDefinitions::RangeData)) { + // Send both, location and data ... + if (trackLocations) + ds << static_cast<qint64>(d.locationId); + messages.append(ds.squeezedData()); + ds.clear(); + ds << d.time << int(QQmlProfilerDefinitions::RangeData) + << static_cast<quint32>(d.detailType) + << (i->location.sourceFile.isEmpty() ? i->url.toString() : + i->location.sourceFile); + } + if (trackLocations) { + ds << static_cast<qint64>(d.locationId); + locations.erase(i); // ... so that we can erase here without missing anything. + } + } else { + // Skip RangeData and RangeLocation: We've already sent them + continue; + } } messages.append(ds.squeezedData()); ds.clear(); } } -qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages) +qint64 QQmlProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages, + bool trackLocations) { while (next != data.length()) { const QQmlProfilerData &nextData = data.at(next); if (nextData.time > until || messages.length() > s_numMessagesPerBatch) return nextData.time; - qQmlProfilerDataToByteArrays(nextData, locations, messages); + qQmlProfilerDataToByteArrays(nextData, locations, messages, trackLocations); ++next; } diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h index 7e13b6c479..1fee5c389f 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.h @@ -60,9 +60,9 @@ class QQmlProfilerAdapter : public QQmlAbstractProfilerAdapter { Q_OBJECT public: QQmlProfilerAdapter(QQmlProfilerService *service, QQmlEnginePrivate *engine); - qint64 sendMessages(qint64 until, QList<QByteArray> &messages) Q_DECL_OVERRIDE; + qint64 sendMessages(qint64 until, QList<QByteArray> &messages, + bool trackLocations) Q_DECL_OVERRIDE; -public slots: void receiveData(const QVector<QQmlProfilerData> &new_data, const QQmlProfiler::LocationHash &locations); diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index e17722bb3d..dba2fd3cc3 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -57,7 +57,7 @@ Q_QML_DEBUG_PLUGIN_LOADER(QQmlAbstractProfilerAdapter) QQmlProfilerServiceImpl::QQmlProfilerServiceImpl(QObject *parent) : QQmlConfigurableDebugService<QQmlProfilerService>(1, parent), - m_waitingForStop(false) + m_waitingForStop(false), m_useMessageTypes(false) { m_timer.start(); QQmlAbstractProfilerAdapter *quickAdapter = @@ -309,7 +309,7 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine) m_waitingForStop = true; foreach (QQmlAbstractProfilerAdapter *profiler, reporting) - profiler->reportData(); + profiler->reportData(m_useMessageTypes); foreach (QQmlAbstractProfilerAdapter *profiler, stopping) profiler->stopProfiling(); @@ -343,7 +343,8 @@ void QQmlProfilerServiceImpl::sendMessages() m_startTimes.erase(m_startTimes.begin()); qint64 next = first->sendMessages(m_startTimes.isEmpty() ? std::numeric_limits<qint64>::max() : - m_startTimes.begin().key(), messages); + m_startTimes.begin().key(), messages, + m_useMessageTypes); if (next != -1) m_startTimes.insert(next, first); @@ -408,16 +409,20 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message) if (!stream.atEnd()) { stream >> flushInterval; m_flushTimer.setInterval(flushInterval); + auto timerStart = static_cast<void(QTimer::*)()>(&QTimer::start); if (flushInterval > 0) { - connect(&m_flushTimer, SIGNAL(timeout()), this, SLOT(flush())); - connect(this, SIGNAL(startFlushTimer()), &m_flushTimer, SLOT(start())); - connect(this, SIGNAL(stopFlushTimer()), &m_flushTimer, SLOT(stop())); + connect(&m_flushTimer, &QTimer::timeout, this, &QQmlProfilerServiceImpl::flush); + connect(this, &QQmlProfilerServiceImpl::startFlushTimer, &m_flushTimer, timerStart); + connect(this, &QQmlProfilerServiceImpl::stopFlushTimer, &m_flushTimer, &QTimer::stop); } else { - disconnect(&m_flushTimer, SIGNAL(timeout()), this, SLOT(flush())); - disconnect(this, SIGNAL(startFlushTimer()), &m_flushTimer, SLOT(start())); - disconnect(this, SIGNAL(stopFlushTimer()), &m_flushTimer, SLOT(stop())); + disconnect(&m_flushTimer, &QTimer::timeout, this, &QQmlProfilerServiceImpl::flush); + disconnect(this, &QQmlProfilerServiceImpl::startFlushTimer, &m_flushTimer, timerStart); + disconnect(this, &QQmlProfilerServiceImpl::stopFlushTimer, + &m_flushTimer, &QTimer::stop); } } + if (!stream.atEnd()) + stream >> m_useMessageTypes; // If engineId == -1 objectForId() and then the cast will return 0. if (enabled) @@ -448,7 +453,7 @@ void QQmlProfilerServiceImpl::flush() } foreach (QQmlAbstractProfilerAdapter *profiler, reporting) - profiler->reportData(); + profiler->reportData(m_useMessageTypes); } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h index 6490e77f44..bbfc32b681 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h @@ -99,9 +99,6 @@ signals: void startFlushTimer(); void stopFlushTimer(); -private slots: - void flush(); - protected: virtual void stateAboutToBeChanged(State state) Q_DECL_OVERRIDE; virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE; @@ -112,10 +109,12 @@ private: void sendMessages(); void addEngineProfiler(QQmlAbstractProfilerAdapter *profiler, QJSEngine *engine); void removeProfilerFromStartTimes(const QQmlAbstractProfilerAdapter *profiler); + void flush(); QElapsedTimer m_timer; QTimer m_flushTimer; bool m_waitingForStop; + bool m_useMessageTypes; QList<QQmlAbstractProfilerAdapter *> m_globalProfilers; QMultiHash<QJSEngine *, QQmlAbstractProfilerAdapter *> m_engineProfilers; diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp index 68a71a5524..eae5e0a795 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp @@ -46,27 +46,26 @@ QV4ProfilerAdapter::QV4ProfilerAdapter(QQmlProfilerService *service, QV4::Execut m_functionCallPos(0), m_memoryPos(0) { setService(service); - engine->enableProfiler(); - connect(this, SIGNAL(profilingEnabled(quint64)), - this, SLOT(forwardEnabled(quint64))); - connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)), - this, SLOT(forwardEnabledWhileWaiting(quint64)), Qt::DirectConnection); - connect(this, SIGNAL(v4ProfilingEnabled(quint64)), - engine->profiler, SLOT(startProfiling(quint64))); - connect(this, SIGNAL(v4ProfilingEnabledWhileWaiting(quint64)), - engine->profiler, SLOT(startProfiling(quint64)), Qt::DirectConnection); - connect(this, SIGNAL(profilingDisabled()), engine->profiler, SLOT(stopProfiling())); - connect(this, SIGNAL(profilingDisabledWhileWaiting()), engine->profiler, SLOT(stopProfiling()), + engine->setProfiler(new QV4::Profiling::Profiler(engine)); + connect(this, &QQmlAbstractProfilerAdapter::profilingEnabled, + this, &QV4ProfilerAdapter::forwardEnabled); + connect(this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting, + this, &QV4ProfilerAdapter::forwardEnabledWhileWaiting, Qt::DirectConnection); + connect(this, &QV4ProfilerAdapter::v4ProfilingEnabled, + engine->profiler(), &QV4::Profiling::Profiler::startProfiling); + connect(this, &QV4ProfilerAdapter::v4ProfilingEnabledWhileWaiting, + engine->profiler(), &QV4::Profiling::Profiler::startProfiling, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabled, + engine->profiler(), &QV4::Profiling::Profiler::stopProfiling); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting, + engine->profiler(), &QV4::Profiling::Profiler::stopProfiling, Qt::DirectConnection); - connect(this, SIGNAL(dataRequested()), engine->profiler, SLOT(reportData())); - connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)), - engine->profiler, SLOT(setTimer(QElapsedTimer))); - connect(engine->profiler, SIGNAL(dataReady(QV4::Profiling::FunctionLocationHash, - QVector<QV4::Profiling::FunctionCallProperties>, - QVector<QV4::Profiling::MemoryAllocationProperties>)), - this, SLOT(receiveData(QV4::Profiling::FunctionLocationHash, - QVector<QV4::Profiling::FunctionCallProperties>, - QVector<QV4::Profiling::MemoryAllocationProperties>))); + connect(this, &QQmlAbstractProfilerAdapter::dataRequested, + engine->profiler(), &QV4::Profiling::Profiler::reportData); + connect(this, &QQmlAbstractProfilerAdapter::referenceTimeKnown, + engine->profiler(), &QV4::Profiling::Profiler::setTimer); + connect(engine->profiler(), &QV4::Profiling::Profiler::dataReady, + this, &QV4ProfilerAdapter::receiveData); } qint64 QV4ProfilerAdapter::appendMemoryEvents(qint64 until, QList<QByteArray> &messages, @@ -77,7 +76,7 @@ qint64 QV4ProfilerAdapter::appendMemoryEvents(qint64 until, QList<QByteArray> &m while (memoryData.length() > m_memoryPos && memoryData[m_memoryPos].timestamp <= until) { const QV4::Profiling::MemoryAllocationProperties &props = memoryData[m_memoryPos]; - d << props.timestamp << MemoryAllocation << props.type << props.size; + d << props.timestamp << int(MemoryAllocation) << int(props.type) << props.size; ++m_memoryPos; messages.append(d.squeezedData()); d.clear(); @@ -105,13 +104,13 @@ qint64 QV4ProfilerAdapter::finalizeMessages(qint64 until, QList<QByteArray> &mes return callNext == -1 ? memoryNext : qMin(callNext, memoryNext); } -qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages) +qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages, + bool trackLocations) { QQmlDebugPacket d; // Make it const, so that we cannot accidentally detach it. const QVector<QV4::Profiling::FunctionCallProperties> &functionCallData = m_functionCallData; - const QV4::Profiling::FunctionLocationHash &functionLocations = m_functionLocations; while (true) { while (!m_stack.isEmpty() && @@ -121,7 +120,7 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message return finalizeMessages(until, messages, m_stack.top(), d); appendMemoryEvents(m_stack.top(), messages, d); - d << m_stack.pop() << RangeEnd << Javascript; + d << m_stack.pop() << int(RangeEnd) << int(Javascript); messages.append(d.squeezedData()); d.clear(); } @@ -133,17 +132,27 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message return finalizeMessages(until, messages, props.start, d); appendMemoryEvents(props.start, messages, d); - auto location = functionLocations.constFind(props.id); - Q_ASSERT(location != functionLocations.constEnd()); - - d << props.start << RangeStart << Javascript; - messages.push_back(d.squeezedData()); - d.clear(); - d << props.start << RangeLocation << Javascript << location->file << location->line - << location->column; - messages.push_back(d.squeezedData()); - d.clear(); - d << props.start << RangeData << Javascript << location->name; + auto location = m_functionLocations.find(props.id); + + d << props.start << int(RangeStart) << int(Javascript); + if (trackLocations) + d << static_cast<qint64>(props.id); + if (location != m_functionLocations.end()) { + messages.push_back(d.squeezedData()); + d.clear(); + d << props.start << int(RangeLocation) << int(Javascript) << location->file << location->line + << location->column; + if (trackLocations) + d << static_cast<qint64>(props.id); + messages.push_back(d.squeezedData()); + d.clear(); + d << props.start << int(RangeData) << int(Javascript) << location->name; + + if (trackLocations) { + d << static_cast<qint64>(props.id); + m_functionLocations.erase(location); + } + } messages.push_back(d.squeezedData()); d.clear(); m_stack.push(props.end); diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h index 968825c346..5d5b83f7ca 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h @@ -67,20 +67,16 @@ class QV4ProfilerAdapter : public QQmlAbstractProfilerAdapter { public: QV4ProfilerAdapter(QQmlProfilerService *service, QV4::ExecutionEngine *engine); - virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages); + virtual qint64 sendMessages(qint64 until, QList<QByteArray> &messages, + bool trackLocations) override; -signals: - void v4ProfilingEnabled(quint64 v4Features); - void v4ProfilingEnabledWhileWaiting(quint64 v4Features); - -public slots: void receiveData(const QV4::Profiling::FunctionLocationHash &, const QVector<QV4::Profiling::FunctionCallProperties> &, const QVector<QV4::Profiling::MemoryAllocationProperties> &); -private slots: - void forwardEnabled(quint64 features); - void forwardEnabledWhileWaiting(quint64 features); +signals: + void v4ProfilingEnabled(quint64 v4Features); + void v4ProfilingEnabledWhileWaiting(quint64 v4Features); private: QV4::Profiling::FunctionLocationHash m_functionLocations; @@ -92,6 +88,8 @@ private: qint64 appendMemoryEvents(qint64 until, QList<QByteArray> &messages, QQmlDebugPacket &d); qint64 finalizeMessages(qint64 until, QList<QByteArray> &messages, qint64 callNext, QQmlDebugPacket &d); + void forwardEnabled(quint64 features); + void forwardEnabledWhileWaiting(quint64 features); static quint64 translateFeatures(quint64 qmlFeatures); }; diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp index 9a2afd367d..0c9fc36463 100644 --- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp @@ -51,20 +51,20 @@ QQuickProfilerAdapter::QQuickProfilerAdapter(QObject *parent) : QQuickProfiler::initialize(this); // We can always do DirectConnection here as all methods are protected by mutexes - connect(this, SIGNAL(profilingEnabled(quint64)), - QQuickProfiler::s_instance, SLOT(startProfilingImpl(quint64)), Qt::DirectConnection); - connect(this, SIGNAL(profilingEnabledWhileWaiting(quint64)), - QQuickProfiler::s_instance, SLOT(startProfilingImpl(quint64)), Qt::DirectConnection); - connect(this, SIGNAL(referenceTimeKnown(QElapsedTimer)), - QQuickProfiler::s_instance, SLOT(setTimer(QElapsedTimer)), Qt::DirectConnection); - connect(this, SIGNAL(profilingDisabled()), - QQuickProfiler::s_instance, SLOT(stopProfilingImpl()), Qt::DirectConnection); - connect(this, SIGNAL(profilingDisabledWhileWaiting()), - QQuickProfiler::s_instance, SLOT(stopProfilingImpl()), Qt::DirectConnection); - connect(this, SIGNAL(dataRequested()), - QQuickProfiler::s_instance, SLOT(reportDataImpl()), Qt::DirectConnection); - connect(QQuickProfiler::s_instance, SIGNAL(dataReady(QVector<QQuickProfilerData>)), - this, SLOT(receiveData(QVector<QQuickProfilerData>)), Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingEnabled, + QQuickProfiler::s_instance, &QQuickProfiler::startProfilingImpl, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting, + QQuickProfiler::s_instance, &QQuickProfiler::startProfilingImpl, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::referenceTimeKnown, + QQuickProfiler::s_instance, &QQuickProfiler::setTimer, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabled, + QQuickProfiler::s_instance, &QQuickProfiler::stopProfilingImpl, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting, + QQuickProfiler::s_instance, &QQuickProfiler::stopProfilingImpl, Qt::DirectConnection); + connect(this, &QQmlAbstractProfilerAdapter::dataRequested, + QQuickProfiler::s_instance, &QQuickProfiler::reportDataImpl, Qt::DirectConnection); + connect(QQuickProfiler::s_instance, &QQuickProfiler::dataReady, + this, &QQuickProfilerAdapter::receiveData, Qt::DirectConnection); } QQuickProfilerAdapter::~QQuickProfilerAdapter() @@ -150,8 +150,10 @@ static void qQuickProfilerDataToByteArrays(const QQuickProfilerData &data, } } -qint64 QQuickProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages) +qint64 QQuickProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages, + bool trackLocations) { + Q_UNUSED(trackLocations); while (next < m_data.size()) { if (m_data[next].time <= until && messages.length() <= s_numMessagesPerBatch) qQuickProfilerDataToByteArrays(m_data[next++], messages); diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h index 0983561d2c..1ad020afd6 100644 --- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h +++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.h @@ -61,9 +61,7 @@ class QQuickProfilerAdapter : public QQmlAbstractProfilerAdapter { public: QQuickProfilerAdapter(QObject *parent = 0); ~QQuickProfilerAdapter(); - qint64 sendMessages(qint64 until, QList<QByteArray> &messages); - -public slots: + qint64 sendMessages(qint64 until, QList<QByteArray> &messages, bool trackLocations) override; void receiveData(const QVector<QQuickProfilerData> &new_data); private: diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index cbde86e389..96b3455790 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -149,15 +149,6 @@ public: static void cleanup(); -private slots: - void wakeEngine(QJSEngine *engine); - void sendMessage(const QString &name, const QByteArray &message); - void sendMessages(const QString &name, const QList<QByteArray> &messages); - void changeServiceState(const QString &serviceName, QQmlDebugService::State state); - void removeThread(); - void receiveMessage(); - void invalidPacket(); - private: friend class QQmlDebugServerThread; friend class QQmlDebugServerFactory; @@ -179,6 +170,13 @@ private: bool canSendMessage(const QString &name); void doSendMessage(const QString &name, const QByteArray &message); + void wakeEngine(QJSEngine *engine); + void sendMessage(const QString &name, const QByteArray &message); + void sendMessages(const QString &name, const QList<QByteArray> &messages); + void changeServiceState(const QString &serviceName, QQmlDebugService::State state); + void removeThread(); + void receiveMessage(); + void invalidPacket(); QQmlDebugServerConnection *m_connection; QHash<QString, QQmlDebugService *> m_plugins; @@ -203,18 +201,22 @@ void QQmlDebugServerImpl::cleanup() if (!server) return; - for (QHash<QString, QQmlDebugService *>::ConstIterator i = server->m_plugins.constBegin(); - i != server->m_plugins.constEnd(); ++i) { - server->m_changeServiceStateCalls.ref(); - QMetaObject::invokeMethod(server, "changeServiceState", Qt::QueuedConnection, - Q_ARG(QString, i.key()), - Q_ARG(QQmlDebugService::State, - QQmlDebugService::NotConnected)); + { + QObject signalSource; + for (QHash<QString, QQmlDebugService *>::ConstIterator i = server->m_plugins.constBegin(); + i != server->m_plugins.constEnd(); ++i) { + server->m_changeServiceStateCalls.ref(); + QString key = i.key(); + // Process this in the server's thread. + connect(&signalSource, &QObject::destroyed, server, [key, server](){ + server->changeServiceState(key, QQmlDebugService::NotConnected); + }, Qt::QueuedConnection); + } } // Wait for changeServiceState calls to finish // (while running an event loop because some services - // might again use slots to execute stuff in the GUI thread) + // might again defer execution of stuff in the GUI thread) QEventLoop loop; while (!server->m_changeServiceStateCalls.testAndSetOrdered(0, 0)) loop.processEvents(); @@ -293,7 +295,7 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() : // Remove the thread immmediately when it finishes, so that we don't have to wait for the // event loop to signal that. - QObject::connect(&m_thread, SIGNAL(finished()), this, SLOT(removeThread()), + QObject::connect(&m_thread, &QThread::finished, this, &QQmlDebugServerImpl::removeThread, Qt::DirectConnection); m_thread.setObjectName(QStringLiteral("QQmlDebugServerThread")); parseArguments(); @@ -631,15 +633,15 @@ bool QQmlDebugServerImpl::addService(const QString &name, QQmlDebugService *serv if (!service || m_plugins.contains(name)) return false; - connect(service, SIGNAL(messageToClient(QString,QByteArray)), - this, SLOT(sendMessage(QString,QByteArray))); - connect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)), - this, SLOT(sendMessages(QString,QList<QByteArray>))); + connect(service, &QQmlDebugService::messageToClient, + this, &QQmlDebugServerImpl::sendMessage); + connect(service, &QQmlDebugService::messagesToClient, + this, &QQmlDebugServerImpl::sendMessages); - connect(service, SIGNAL(attachedToEngine(QJSEngine*)), - this, SLOT(wakeEngine(QJSEngine*)), Qt::QueuedConnection); - connect(service, SIGNAL(detachedFromEngine(QJSEngine*)), - this, SLOT(wakeEngine(QJSEngine*)), Qt::QueuedConnection); + connect(service, &QQmlDebugService::attachedToEngine, + this, &QQmlDebugServerImpl::wakeEngine, Qt::QueuedConnection); + connect(service, &QQmlDebugService::detachedFromEngine, + this, &QQmlDebugServerImpl::wakeEngine, Qt::QueuedConnection); service->setState(QQmlDebugService::Unavailable); m_plugins.insert(name, service); @@ -659,15 +661,15 @@ bool QQmlDebugServerImpl::removeService(const QString &name) m_plugins.remove(name); service->setState(QQmlDebugService::NotConnected); - disconnect(service, SIGNAL(detachedFromEngine(QJSEngine*)), - this, SLOT(wakeEngine(QJSEngine*))); - disconnect(service, SIGNAL(attachedToEngine(QJSEngine*)), - this, SLOT(wakeEngine(QJSEngine*))); + disconnect(service, &QQmlDebugService::detachedFromEngine, + this, &QQmlDebugServerImpl::wakeEngine); + disconnect(service, &QQmlDebugService::attachedToEngine, + this, &QQmlDebugServerImpl::wakeEngine); - disconnect(service, SIGNAL(messagesToClient(QString,QList<QByteArray>)), - this, SLOT(sendMessages(QString,QList<QByteArray>))); - disconnect(service, SIGNAL(messageToClient(QString,QByteArray)), - this, SLOT(sendMessage(QString,QByteArray))); + disconnect(service, &QQmlDebugService::messagesToClient, + this, &QQmlDebugServerImpl::sendMessages); + disconnect(service, &QQmlDebugService::messageToClient, + this, &QQmlDebugServerImpl::sendMessage); return true; } @@ -738,8 +740,10 @@ void QQmlDebugServerImpl::EngineCondition::wake() void QQmlDebugServerImpl::setDevice(QIODevice *socket) { m_protocol = new QPacketProtocol(socket, this); - QObject::connect(m_protocol, SIGNAL(readyRead()), this, SLOT(receiveMessage())); - QObject::connect(m_protocol, SIGNAL(invalidPacket()), this, SLOT(invalidPacket())); + QObject::connect(m_protocol, &QPacketProtocol::readyRead, + this, &QQmlDebugServerImpl::receiveMessage); + QObject::connect(m_protocol, &QPacketProtocol::invalidPacket, + this, &QQmlDebugServerImpl::invalidPacket); if (blockingMode()) m_protocol->waitForReadyRead(-1); diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp index 3d64312b16..b305c3f535 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp @@ -65,10 +65,8 @@ public: void waitForConnection(); void flush(); -private slots: - void newConnection(); - private: + void newConnection(); bool listen(); int m_portFrom; @@ -152,7 +150,8 @@ void QTcpServerConnection::flush() bool QTcpServerConnection::listen() { m_tcpServer = new QTcpServer(this); - QObject::connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); + QObject::connect(m_tcpServer, &QTcpServer::newConnection, + this, &QTcpServerConnection::newConnection); QHostAddress hostaddress; if (!m_hostaddress.isEmpty()) { if (!hostaddress.setAddress(m_hostaddress)) { diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index 3728126dd9..907fbe9273 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs +QT_FOR_CONFIG += qml # Utilities SUBDIRS += \ @@ -7,9 +8,13 @@ SUBDIRS += \ # Connectors SUBDIRS += \ qmldbg_native \ - qmldbg_server \ + qmldbg_server + +qtConfig(qml-network) { + SUBDIRS += \ qmldbg_local \ qmldbg_tcp +} # Services SUBDIRS += \ diff --git a/src/plugins/qmltooling/shared/qqmldebugserver.h b/src/plugins/qmltooling/shared/qqmldebugserver.h index 424c7c4120..109f1e246c 100644 --- a/src/plugins/qmltooling/shared/qqmldebugserver.h +++ b/src/plugins/qmltooling/shared/qqmldebugserver.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class QQmlDebugServer : protected QQmlDebugConnector +class QQmlDebugServer : public QQmlDebugConnector { Q_OBJECT public: |