diff options
Diffstat (limited to 'src/plugins/qmltooling')
26 files changed, 167 insertions, 145 deletions
diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp index e541810330..5460d617dd 100644 --- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp +++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp @@ -247,7 +247,7 @@ void QPacketProtocol::readyToRead() 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; + d->dev = nullptr; emit invalidPacket(); return; } diff --git a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h index 7fd722f17f..35edb568aa 100644 --- a/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h +++ b/src/plugins/qmltooling/packetprotocol/qpacketprotocol_p.h @@ -63,7 +63,7 @@ class QPacketProtocol : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QPacketProtocol) public: - explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0); + explicit QPacketProtocol(QIODevice *dev, QObject *parent = nullptr); void send(const QByteArray &data); qint64 packetsAvailable() const; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp index 9315adf4ce..3851cdc71f 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp @@ -52,7 +52,7 @@ QQmlDebugService *QQmlDebuggerServiceFactory::create(const QString &key) if (key == QV4DebugServiceImpl::s_key) return new QV4DebugServiceImpl(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 182e4257f8..288ad243ce 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) : - QQmlEngineDebugService(2, parent), m_watch(new QQmlWatcher(this)), m_statesDelegate(0) + QQmlEngineDebugService(2, parent), m_watch(new QQmlWatcher(this)), m_statesDelegate(nullptr) { connect(m_watch, &QQmlWatcher::propertyChanged, this, &QQmlEngineDebugServiceImpl::propertyChanged); @@ -209,19 +209,32 @@ QVariant QQmlEngineDebugServiceImpl::valueContents(QVariant value) const } if (QQmlValueTypeFactory::isValueType(userType)) { + switch (userType) { + case QMetaType::QRect: + case QMetaType::QRectF: + case QMetaType::QPoint: + case QMetaType::QPointF: + case QMetaType::QSize: + case QMetaType::QSizeF: + case QMetaType::QFont: + // Don't call the toString() method on those. The stream operators are better. + return value; + default: + break; + } + const QMetaObject *mo = QQmlValueTypeFactory::metaObjectForMetaType(userType); if (mo) { - int toStringIndex = mo->indexOfMethod("toString"); + int toStringIndex = mo->indexOfMethod("toString()"); if (toStringIndex != -1) { QMetaMethod mm = mo->method(toStringIndex); - QMetaType info(userType); QString s; - if (info.flags() & QMetaType::IsGadget - && mm.invokeOnGadget(value.data(), Q_RETURN_ARG(QString, s))) + if (mm.invokeOnGadget(value.data(), Q_RETURN_ARG(QString, s))) return s; } } + // We expect all QML value types to either have a toString() method or stream operators return value; } @@ -337,6 +350,9 @@ void QQmlEngineDebugServiceImpl::buildObjectList(QDataStream &message, QQmlContext *ctxt, const QList<QPointer<QObject> > &instances) { + if (!ctxt->isValid()) + return; + QQmlContextData *p = QQmlContextData::get(ctxt); QString ctxtName = ctxt->objectName(); @@ -399,11 +415,8 @@ QQmlEngineDebugServiceImpl::objectData(QObject *object) } QQmlContext *context = qmlContext(object); - if (context) { - QQmlContextData *cdata = QQmlContextData::get(context); - if (cdata) - rv.idString = cdata->findObjectId(object); - } + if (context && context->isValid()) + rv.idString = QQmlContextData::get(context)->findObjectId(object); rv.objectName = object->objectName(); rv.objectId = QQmlDebugService::idForObject(object); @@ -564,14 +577,14 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message) QObject *object = QQmlDebugService::objectForId(objectId); QQmlContext *context = qmlContext(object); - if (!context) { + if (!context || !context->isValid()) { QQmlEngine *engine = qobject_cast<QQmlEngine *>( QQmlDebugService::objectForId(engineId)); if (engine && m_engines.contains(engine)) context = engine->rootContext(); } QVariant result; - if (context) { + if (context && context->isValid()) { QQmlExpression exprObj(context, object, expr); bool undefined = false; QVariant value = exprObj.evaluate(&undefined); @@ -632,7 +645,7 @@ bool QQmlEngineDebugServiceImpl::setBinding(int objectId, QObject *object = objectForId(objectId); QQmlContext *context = qmlContext(object); - if (object && context) { + if (object && context && context->isValid()) { QQmlProperty property(object, propertyName, context); if (property.isValid()) { @@ -677,7 +690,7 @@ bool QQmlEngineDebugServiceImpl::resetBinding(int objectId, const QString &prope QObject *object = objectForId(objectId); QQmlContext *context = qmlContext(object); - if (object && context) { + if (object && context && context->isValid()) { QStringRef parentPropertyRef(&propertyName); const int idx = parentPropertyRef.indexOf(QLatin1Char('.')); if (idx != -1) @@ -713,7 +726,7 @@ bool QQmlEngineDebugServiceImpl::resetBinding(int objectId, const QString &prope if (hasValidSignal(object, propertyName)) { QQmlProperty property(object, propertyName, context); - QQmlPropertyPrivate::setSignalExpression(property, 0); + QQmlPropertyPrivate::setSignalExpression(property, nullptr); return true; } @@ -732,11 +745,9 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth { QObject *object = objectForId(objectId); QQmlContext *context = qmlContext(object); - if (!object || !context || !context->engine()) + if (!object || !context || !context->isValid()) return false; QQmlContextData *contextData = QQmlContextData::get(context); - if (!contextData) - return false; QQmlPropertyData dummy; QQmlPropertyData *prop = @@ -760,7 +771,7 @@ bool QQmlEngineDebugServiceImpl::setMethodBody(int objectId, const QString &meth QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(object); Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this - QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine(object)->handle()); + QV4::ExecutionEngine *v4 = qmlEngine(object)->handle(); QV4::Scope scope(v4); int lineNumber = 0; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp index cbbbb2ceb7..86571e6cbe 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp @@ -61,12 +61,12 @@ public: QObject *object, int debugId, const QMetaProperty &prop, - QQmlWatcher *parent = 0); + QQmlWatcher *parent = nullptr); QQmlWatchProxy(int id, QQmlExpression *exp, int debugId, - QQmlWatcher *parent = 0); + QQmlWatcher *parent = nullptr); public slots: void notifyValueChanged(); // Needs to be a slot because of QQmlPropertyPrivate::connect() @@ -86,7 +86,7 @@ QQmlWatchProxy::QQmlWatchProxy(int id, QQmlExpression *exp, int debugId, QQmlWatcher *parent) -: QObject(parent), m_id(id), m_watch(parent), m_object(0), m_debugId(debugId), m_expr(exp) +: QObject(parent), m_id(id), m_watch(parent), m_object(nullptr), m_debugId(debugId), m_expr(exp) { QObject::connect(m_expr, &QQmlExpression::valueChanged, this, &QQmlWatchProxy::notifyValueChanged); @@ -97,7 +97,7 @@ QQmlWatchProxy::QQmlWatchProxy(int id, int debugId, const QMetaProperty &prop, QQmlWatcher *parent) -: QObject(parent), m_id(id), m_watch(parent), m_object(object), m_debugId(debugId), m_property(prop), m_expr(0) +: QObject(parent), m_id(id), m_watch(parent), m_object(object), m_debugId(debugId), m_property(prop), m_expr(nullptr) { static int refreshIdx = -1; if(refreshIdx == -1) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index a538956e8e..c86f3d1803 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -69,19 +69,19 @@ QV4::Heap::ExecutionContext *QV4DataCollector::findContext(int frame) { QV4::CppStackFrame *f = findFrame(frame); - return f ? f->context()->d() : 0; + return f ? f->context()->d() : nullptr; } QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) { if (!ctx) - return 0; + return nullptr; for (; scope > 0 && ctx; --scope) ctx = ctx->outer; return (ctx && ctx->type == QV4::Heap::ExecutionContext::Type_CallContext) ? - static_cast<QV4::Heap::CallContext *>(ctx) : 0; + static_cast<QV4::Heap::CallContext *>(ctx) : nullptr; } QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes(int frame) @@ -139,16 +139,16 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution switch (value->type()) { case QV4::Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); - return 0; + return nullptr; case QV4::Value::Undefined_Type: dict.insert(valueKey, QJsonValue::Undefined); - return 0; + return nullptr; case QV4::Value::Null_Type: dict.insert(valueKey, QJsonValue::Null); - return 0; + return nullptr; case QV4::Value::Boolean_Type: dict.insert(valueKey, value->booleanValue()); - return 0; + return nullptr; case QV4::Value::Managed_Type: if (const QV4::String *s = value->as<QV4::String>()) { dict.insert(valueKey, s->toQString()); @@ -176,10 +176,10 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution } else { Q_UNREACHABLE(); } - return 0; + return nullptr; case QV4::Value::Integer_Type: dict.insert(valueKey, value->integerValue()); - return 0; + return nullptr; default: {// double const double val = value->doubleValue(); if (qIsFinite(val)) @@ -190,7 +190,7 @@ const QV4::Object *collectProperty(const QV4::ScopedValue &value, QV4::Execution dict.insert(valueKey, QStringLiteral("-Infinity")); else dict.insert(valueKey, QStringLiteral("Infinity")); - return 0; + return nullptr; } } } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 1581cf637d..a1ed211a55 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -71,8 +71,8 @@ QV4Debugger::QV4Debugger(QV4::ExecutionEngine *engine) , m_haveBreakPoints(false) , m_breakOnThrow(false) , m_returnedValue(engine, QV4::Primitive::undefinedValue()) - , m_gatherSources(0) - , m_runningJob(0) + , m_gatherSources(nullptr) + , m_runningJob(nullptr) , m_collector(engine) { static int debuggerId = qRegisterMetaType<QV4Debugger*>(); @@ -182,14 +182,14 @@ void QV4Debugger::maybeBreakAtInstruction() if (m_gatherSources) { m_gatherSources->run(); delete m_gatherSources; - m_gatherSources = 0; + m_gatherSources = nullptr; } switch (m_stepping) { case StepOver: if (m_currentFrame != m_engine->currentStackFrame) break; - // fall through + Q_FALLTHROUGH(); case StepIn: pauseAndWait(Step); return; @@ -295,11 +295,11 @@ bool QV4Debugger::reallyHitTheBreakPoint(const QString &filename, int linenr) if (condition.isEmpty()) return true; - Q_ASSERT(m_runningJob == 0); + Q_ASSERT(m_runningJob == nullptr); EvalJob evilJob(m_engine, condition); m_runningJob = &evilJob; m_runningJob->run(); - m_runningJob = 0; + m_runningJob = nullptr; return evilJob.resultAsBoolean(); } @@ -313,7 +313,7 @@ void QV4Debugger::runInEngine(QV4DebugJob *job) void QV4Debugger::runInEngine_havingLock(QV4DebugJob *job) { Q_ASSERT(job); - Q_ASSERT(m_runningJob == 0); + Q_ASSERT(m_runningJob == nullptr); m_runningJob = job; if (state() == Paused) @@ -321,7 +321,7 @@ void QV4Debugger::runInEngine_havingLock(QV4DebugJob *job) else emit scheduleJob(); m_jobIsRunning.wait(&m_lock); - m_runningJob = 0; + m_runningJob = nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 87e75c49b5..71645579c5 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -56,13 +56,13 @@ QV4Debugger *QV4DebuggerAgent::pausedDebugger() const if (debugger->state() == QV4Debugger::Paused) return debugger; } - return 0; + return nullptr; } bool QV4DebuggerAgent::isRunning() const { // "running" means none of the engines are paused. - return pausedDebugger() == 0; + return pausedDebugger() == nullptr; } void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseReason reason) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 6f254c9e28..5b049ab521 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -208,7 +208,7 @@ void ValueLookupJob::run() QScopedPointer<QObject> scopeObject; QV4::ExecutionEngine *engine = collector->engine(); QV4::Scope scope(engine); - QV4::Heap::ExecutionContext *qmlContext = 0; + QV4::Heap::ExecutionContext *qmlContext = nullptr; if (engine->qmlEngine() && !engine->qmlContext()) { scopeObject.reset(new QObject); qmlContext = QV4::QmlContext::create(engine->currentContext(), diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index fca811cb28..61209e08cb 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -98,7 +98,7 @@ public: debugService->send(response); } - debugService = 0; + debugService = nullptr; seq = QJsonValue(); req = QJsonObject(); response = QJsonObject(); @@ -702,7 +702,7 @@ void QV4DebugServiceImpl::engineAdded(QJSEngine *engine) { QMutexLocker lock(&m_configMutex); if (engine) { - QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *ee = engine->handle(); if (QQmlDebugConnector *server = QQmlDebugConnector::instance()) { if (ee) { QV4Debugger *debugger = new QV4Debugger(ee); @@ -720,7 +720,7 @@ void QV4DebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine) { QMutexLocker lock(&m_configMutex); if (engine){ - const QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); + const QV4::ExecutionEngine *ee = engine->handle(); if (ee) { QV4Debugger *debugger = qobject_cast<QV4Debugger *>(ee->debugger()); if (debugger) diff --git a/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp b/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp index c7307db240..0d6cd45354 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/highlight.cpp @@ -100,7 +100,7 @@ void Highlight::adjust() return; bool success = false; - m_transform = m_item->itemTransform(0, &success); + m_transform = m_item->itemTransform(nullptr, &success); if (!success) m_transform = QTransform(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp index bc146b176c..1781670cf3 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/inspecttool.cpp @@ -62,8 +62,8 @@ InspectTool::InspectTool(QQuickWindowInspector *inspector, QQuickWindow *view) : m_contentItem(view->contentItem()), m_touchTimestamp(0), m_hoverHighlight(new HoverHighlight(inspector->overlay())), - m_lastItem(0), - m_lastClickedItem(0) + m_lastItem(nullptr), + m_lastClickedItem(nullptr) { //Timer to display selected item's name m_nameDisplayTimer.setSingleShot(true); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp index d0d8d62615..fa27adedfd 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp @@ -49,7 +49,7 @@ class QQmlInspectorServiceImpl : public QQmlInspectorService { Q_OBJECT public: - QQmlInspectorServiceImpl(QObject *parent = 0); + QQmlInspectorServiceImpl(QObject *parent = nullptr); void addWindow(QQuickWindow *window) override; void setParentWindow(QQuickWindow *window, QWindow *parent) override; @@ -72,7 +72,7 @@ private: }; QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(QObject *parent): - QQmlInspectorService(1, parent), m_globalInspector(0) + QQmlInspectorService(1, parent), m_globalInspector(nullptr) { connect(this, &QQmlInspectorServiceImpl::scheduleMessage, this, &QQmlInspectorServiceImpl::messageFromClient, Qt::QueuedConnection); @@ -95,7 +95,7 @@ QmlJSDebugger::GlobalInspector *QQmlInspectorServiceImpl::checkInspector() } } else if (m_globalInspector) { delete m_globalInspector; - m_globalInspector = 0; + m_globalInspector = nullptr; } return m_globalInspector; } @@ -138,7 +138,7 @@ void QQmlInspectorServiceImpl::messageFromClient(const QByteArray &message) QQmlDebugService *QQmlInspectorServiceFactory::create(const QString &key) { - return key == QQmlInspectorServiceImpl::s_key ? new QQmlInspectorServiceImpl(this) : 0; + return key == QQmlInspectorServiceImpl::s_key ? new QQmlInspectorServiceImpl(this) : nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp index 16056addbd..09eb6bfc28 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp @@ -54,14 +54,14 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos, QQuickItem *overlay) { if (item == overlay) - return 0; + return nullptr; if (!item->isVisible() || item->opacity() == 0.0) - return 0; + return nullptr; if (item->flags() & QQuickItem::ItemClipsChildrenToShape) { if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return 0; + return nullptr; } QList<QQuickItem *> children = QQuickItemPrivate::get(item)->paintOrderChildItems(); @@ -73,10 +73,10 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos, } if (!(item->flags() & QQuickItem::ItemHasContents)) - return 0; + return nullptr; if (!QRectF(0, 0, item->width(), item->height()).contains(pos)) - return 0; + return nullptr; return item; } @@ -111,8 +111,8 @@ QQuickWindowInspector::QQuickWindowInspector(QQuickWindow *quickWindow, QObject QObject(parent), m_overlay(new QQuickItem), m_window(quickWindow), - m_parentWindow(0), - m_tool(0) + m_parentWindow(nullptr), + m_tool(nullptr) { setParentWindow(quickWindow); @@ -169,13 +169,29 @@ bool QQuickWindowInspector::eventFilter(QObject *obj, QEvent *event) return QObject::eventFilter(obj, event); } +static Qt::WindowFlags fixFlags(Qt::WindowFlags flags) +{ + // If only the type flag is given, some other window flags are automatically assumed. When we + // add a flag, we need to make those explicit. + switch (flags) { + case Qt::Window: + return flags | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint + | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; + case Qt::Dialog: + case Qt::Tool: + return flags | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; + default: + return flags; + } +} + void QQuickWindowInspector::setShowAppOnTop(bool appOnTop) { if (!m_parentWindow) return; Qt::WindowFlags flags = m_parentWindow->flags(); - Qt::WindowFlags newFlags = appOnTop ? (flags | Qt::WindowStaysOnTopHint) : + Qt::WindowFlags newFlags = appOnTop ? (fixFlags(flags) | Qt::WindowStaysOnTopHint) : (flags & ~Qt::WindowStaysOnTopHint); if (newFlags != flags) m_parentWindow->setFlags(newFlags); @@ -183,7 +199,7 @@ void QQuickWindowInspector::setShowAppOnTop(bool appOnTop) bool QQuickWindowInspector::isEnabled() const { - return m_tool != 0; + return m_tool != nullptr; } void QQuickWindowInspector::setEnabled(bool enabled) @@ -192,7 +208,7 @@ void QQuickWindowInspector::setEnabled(bool enabled) m_tool = new InspectTool(this, m_window); } else { delete m_tool; - m_tool = 0; + m_tool = nullptr; } } diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp index e60644518f..1708166a8a 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp @@ -55,7 +55,7 @@ class QLocalClientConnection : public QQmlDebugServerConnection public: QLocalClientConnection(); - ~QLocalClientConnection(); + ~QLocalClientConnection() override; void setServer(QQmlDebugServer *server) override; bool setPortRange(int portFrom, int portTo, bool block, const QString &hostaddress) override; @@ -71,18 +71,13 @@ private: void connectionEstablished(); bool connectToServer(); - bool m_block; + bool m_block = false; QString m_filename; - QLocalSocket *m_socket; - QQmlDebugServer *m_debugServer; + QLocalSocket *m_socket = nullptr; + QQmlDebugServer *m_debugServer = nullptr; }; -QLocalClientConnection::QLocalClientConnection() : - m_block(false), - m_socket(0), - m_debugServer(0) -{ -} +QLocalClientConnection::QLocalClientConnection() { } QLocalClientConnection::~QLocalClientConnection() { @@ -106,7 +101,7 @@ void QLocalClientConnection::disconnect() m_socket->waitForBytesWritten(); m_socket->deleteLater(); - m_socket = 0; + m_socket = nullptr; } bool QLocalClientConnection::setPortRange(int portFrom, int portTo, bool block, @@ -161,7 +156,7 @@ void QLocalClientConnection::connectionEstablished() QQmlDebugServerConnection *QLocalClientConnectionFactory::create(const QString &key) { - return (key == QLatin1String("QLocalClientConnection") ? new QLocalClientConnection : 0); + return (key == QLatin1String("QLocalClientConnection") ? new QLocalClientConnection : nullptr); } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp index bdfed03a40..2bf9210b37 100644 --- a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp +++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp @@ -51,7 +51,7 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, } QDebugMessageServiceImpl::QDebugMessageServiceImpl(QObject *parent) : - QDebugMessageService(2, parent), oldMsgHandler(0), + QDebugMessageService(2, parent), oldMsgHandler(nullptr), prevState(QQmlDebugService::NotConnected) { // don't execute stateChanged() in parallel diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp index 860d654128..177ca1fe80 100644 --- a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp +++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp @@ -48,7 +48,7 @@ QQmlDebugService *QDebugMessageServiceFactory::create(const QString &key) if (key == QDebugMessageServiceImpl::s_key) return new QDebugMessageServiceImpl(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp index a4b3455eff..93ac875e2d 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp @@ -224,7 +224,7 @@ QQmlDebugService *QQmlNativeDebugConnector::service(const QString &name) const if ((*i)->name() == name) return *i; } - return 0; + return nullptr; } void QQmlNativeDebugConnector::addEngine(QJSEngine *engine) @@ -360,7 +360,7 @@ void QQmlNativeDebugConnector::sendMessages(const QString &name, const QList<QBy QQmlDebugConnector *QQmlNativeDebugConnectorFactory::create(const QString &key) { - return key == QLatin1String("QQmlNativeDebugConnector") ? new QQmlNativeDebugConnector : 0; + return key == QLatin1String("QQmlNativeDebugConnector") ? new QQmlNativeDebugConnector : nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index eeedb59ce6..718975275a 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -229,7 +229,7 @@ private: QV4::ExecutionEngine *m_engine; QQmlNativeDebugServiceImpl *m_service; - QV4::CppStackFrame *m_currentFrame = 0; + QV4::CppStackFrame *m_currentFrame = nullptr; Speed m_stepping; bool m_pauseRequested; bool m_runningJob; @@ -457,7 +457,7 @@ void Collector::collect(QJsonArray *out, const QString &parentIName, const QStri void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &arguments) { TRACE_PROTOCOL("Build variables"); - QV4::CppStackFrame *frame = 0; + QV4::CppStackFrame *frame = nullptr; decodeFrame(arguments.value(QLatin1String("context")).toString(), &frame); if (!frame) { setError(response, QStringLiteral("No stack frame passed")); @@ -500,7 +500,7 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject &arguments) { TRACE_PROTOCOL("Evaluate expressions"); - QV4::CppStackFrame *frame = 0; + QV4::CppStackFrame *frame = nullptr; decodeFrame(arguments.value(QLatin1String("context")).toString(), &frame); if (!frame) { setError(response, QStringLiteral("No stack frame passed")); @@ -713,7 +713,7 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeAdded(QJSEngine *engine) { TRACE_PROTOCOL("Adding engine" << engine); if (engine) { - QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *ee = engine->handle(); TRACE_PROTOCOL("Adding execution engine" << ee); if (ee) { NativeDebugger *debugger = new NativeDebugger(this, ee); @@ -729,7 +729,7 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine) { TRACE_PROTOCOL("Removing engine" << engine); if (engine) { - QV4::ExecutionEngine *executionEngine = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *executionEngine = engine->handle(); const auto debuggersCopy = m_debuggers; for (NativeDebugger *debugger : debuggersCopy) { if (debugger->engine() == executionEngine) diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp index 1841c82d5d..c0b74c74ff 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp @@ -48,7 +48,7 @@ QQmlDebugService *QQmlNativeDebugServiceFactory::create(const QString &key) if (key == QQmlNativeDebugServiceImpl::s_key) return new QQmlNativeDebugServiceImpl(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index c388c6e74a..eb6fbce101 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -126,7 +126,7 @@ void QQmlProfilerServiceImpl::engineAboutToBeAdded(QJSEngine *engine) = new QQmlProfilerAdapter(this, &(enginePrivate->typeLoader)); addEngineProfiler(compileAdapter, engine); } - QV4ProfilerAdapter *v4Adapter = new QV4ProfilerAdapter(this, QV8Engine::getV4(engine->handle())); + QV4ProfilerAdapter *v4Adapter = new QV4ProfilerAdapter(this, engine->handle()); addEngineProfiler(v4Adapter, engine); QQmlConfigurableDebugService<QQmlProfilerService>::engineAboutToBeAdded(engine); } @@ -240,9 +240,9 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features QQmlDebugPacket d; - d << m_timer.nsecsElapsed() << (int)Event << (int)StartTrace; + d << m_timer.nsecsElapsed() << static_cast<qint32>(Event) << static_cast<qint32>(StartTrace); bool startedAny = false; - if (engine != 0) { + if (engine != nullptr) { const auto range = qAsConst(m_engineProfilers).equal_range(engine); for (auto it = range.first; it != range.second; ++it) { QQmlAbstractProfilerAdapter *profiler = *it; @@ -296,10 +296,11 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine) for (QMultiHash<QJSEngine *, QQmlAbstractProfilerAdapter *>::iterator i(m_engineProfilers.begin()); i != m_engineProfilers.end(); ++i) { if (i.value()->isRunning()) { - if (engine == 0 || i.key() == engine) { - m_startTimes.insert(-1, i.value()); + m_startTimes.insert(-1, i.value()); + if (engine == nullptr || i.key() == engine) { stopping << i.value(); } else { + reporting << i.value(); stillRunning = true; } } @@ -338,7 +339,8 @@ void QQmlProfilerServiceImpl::sendMessages() QQmlDebugPacket traceEnd; if (m_waitingForStop) { - traceEnd << m_timer.nsecsElapsed() << (int)Event << (int)EndTrace; + traceEnd << m_timer.nsecsElapsed() << static_cast<qint32>(Event) + << static_cast<qint32>(EndTrace); QSet<QJSEngine *> seen; for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_startTimes)) { @@ -368,25 +370,32 @@ void QQmlProfilerServiceImpl::sendMessages() } } + bool stillRunning = false; + for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { + if (profiler->isRunning()) { + stillRunning = true; + break; + } + } + if (m_waitingForStop) { - //indicate completion + // EndTrace can be sent multiple times, as it's engine specific. messages << traceEnd.data(); - QQmlDebugPacket ds; - ds << (qint64)-1 << (int)Complete; - messages << ds.data(); - m_waitingForStop = false; + if (!stillRunning) { + // Complete is only sent once, when no engines are running anymore. + QQmlDebugPacket ds; + ds << static_cast<qint64>(-1) << static_cast<qint32>(Complete); + messages << ds.data(); + m_waitingForStop = false; + } } emit messagesToClient(name(), messages); // Restart flushing if any profilers are still running - for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { - if (profiler->isRunning()) { - emit startFlushTimer(); - break; - } - } + if (stillRunning) + emit startFlushTimer(); } void QQmlProfilerServiceImpl::stateAboutToBeChanged(QQmlDebugService::State newState) @@ -414,7 +423,7 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message) int engineId = -1; quint64 features = std::numeric_limits<quint64>::max(); bool enabled; - uint flushInterval = 0; + quint32 flushInterval = 0; stream >> enabled; if (!stream.atEnd()) stream >> engineId; @@ -422,7 +431,9 @@ void QQmlProfilerServiceImpl::messageReceived(const QByteArray &message) stream >> features; if (!stream.atEnd()) { stream >> flushInterval; - m_flushTimer.setInterval(flushInterval); + m_flushTimer.setInterval( + static_cast<int>(qMin(flushInterval, + static_cast<quint32>(std::numeric_limits<int>::max())))); auto timerStart = static_cast<void(QTimer::*)()>(&QTimer::start); if (flushInterval > 0) { connect(&m_flushTimer, &QTimer::timeout, this, &QQmlProfilerServiceImpl::flush); diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp index 0cd3e0b4ab..81a1a35d18 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.cpp @@ -51,7 +51,7 @@ QQmlDebugService *QQmlProfilerServiceFactory::create(const QString &key) if (key == QQmlEngineControlServiceImpl::s_key) return new QQmlEngineControlServiceImpl(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.cpp b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.cpp index f38307b1f7..66addee2e8 100644 --- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.cpp +++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE QQmlAbstractProfilerAdapter *QQuickProfilerAdapterFactory::create(const QString &key) { if (key != QLatin1String("QQuickProfilerAdapter")) - return 0; + return nullptr; return new QQuickProfilerAdapter(this); } diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index f87ade568b..1814e28b83 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -88,7 +88,7 @@ class QQmlDebugServerImpl; class QQmlDebugServerThread : public QThread { public: - QQmlDebugServerThread() : m_server(0), m_portFrom(-1), m_portTo(-1) {} + QQmlDebugServerThread() : m_server(nullptr), m_portFrom(-1), m_portTo(-1) {} void setServer(QQmlDebugServerImpl *server) { @@ -228,7 +228,7 @@ void QQmlDebugServerImpl::cleanup() void QQmlDebugServerThread::run() { - Q_ASSERT_X(m_server != 0, Q_FUNC_INFO, "There should always be a debug server available here."); + Q_ASSERT_X(m_server != nullptr, Q_FUNC_INFO, "There should always be a debug server available here."); QQmlDebugServerConnection *connection = loadQQmlDebugServerConnection(m_pluginName); if (connection) { { @@ -274,7 +274,7 @@ static void cleanupOnShutdown() } QQmlDebugServerImpl::QQmlDebugServerImpl() : - m_connection(0), + m_connection(nullptr), m_gotHello(false), m_blockingMode(false), m_clientSupportsMultiPackets(false) @@ -570,7 +570,7 @@ void QQmlDebugServerImpl::removeThread() QThread *parentThread = m_thread.thread(); delete m_connection; - m_connection = 0; + m_connection = nullptr; // Move it back to the parent thread so that we can potentially restart it on a new thread. moveToThread(parentThread); @@ -755,13 +755,13 @@ void QQmlDebugServerImpl::invalidPacket() m_connection->disconnect(); // protocol might still be processing packages at this point m_protocol->deleteLater(); - m_protocol = 0; + m_protocol = nullptr; } QQmlDebugConnector *QQmlDebugServerFactory::create(const QString &key) { // Cannot parent it to this because it gets moved to another thread - return (key == QLatin1String("QQmlDebugServer") ? new QQmlDebugServerImpl : 0); + return (key == QLatin1String("QQmlDebugServer") ? new QQmlDebugServerImpl : nullptr); } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp index c2aafda863..42442b07e7 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp @@ -54,7 +54,7 @@ class QTcpServerConnection : public QQmlDebugServerConnection public: QTcpServerConnection(); - ~QTcpServerConnection(); + ~QTcpServerConnection() override; void setServer(QQmlDebugServer *server) override; bool setPortRange(int portFrom, int portTo, bool block, const QString &hostaddress) override; @@ -70,24 +70,16 @@ private: void newConnection(); bool listen(); - int m_portFrom; - int m_portTo; - bool m_block; + int m_portFrom = 0; + int m_portTo = 0; + bool m_block = false; QString m_hostaddress; - QTcpSocket *m_socket; - QTcpServer *m_tcpServer; - QQmlDebugServer *m_debugServer; + QTcpSocket *m_socket = nullptr; + QTcpServer *m_tcpServer = nullptr; + QQmlDebugServer *m_debugServer = nullptr; }; -QTcpServerConnection::QTcpServerConnection() : - m_portFrom(0), - m_portTo(0), - m_block(false), - m_socket(0), - m_tcpServer(0), - m_debugServer(0) -{ -} +QTcpServerConnection::QTcpServerConnection() {} QTcpServerConnection::~QTcpServerConnection() { @@ -116,7 +108,7 @@ void QTcpServerConnection::disconnect() } m_socket->deleteLater(); - m_socket = 0; + m_socket = nullptr; } bool QTcpServerConnection::setPortRange(int portFrom, int portTo, bool block, @@ -199,7 +191,7 @@ void QTcpServerConnection::newConnection() QQmlDebugServerConnection *QTcpServerConnectionFactory::create(const QString &key) { - return (key == QLatin1String("QTcpServerConnection") ? new QTcpServerConnection : 0); + return (key == QLatin1String("QTcpServerConnection") ? new QTcpServerConnection : nullptr); } QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index 5895169ca0..119415372b 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -14,26 +14,23 @@ qmldbg_native.depends = packetprotocol qmldbg_server.depends = packetprotocol qtConfig(qml-network) { + qtConfig(localserver): SUBDIRS += qmldbg_local + SUBDIRS += \ - qmldbg_local \ qmldbg_tcp } # Services SUBDIRS += \ qmldbg_messages \ - qmldbg_profiler + qmldbg_profiler \ + qmldbg_debugger \ + qmldbg_nativedebugger + qmldbg_messages.depends = packetprotocol qmldbg_profiler.depends = packetprotocol - -qtConfig(qml-interpreter) { - SUBDIRS += \ - qmldbg_debugger \ - qmldbg_nativedebugger - - qmldbg_debugger.depends = packetprotocol - qmldbg_nativedebugger.depends = packetprotocol -} +qmldbg_debugger.depends = packetprotocol +qmldbg_nativedebugger.depends = packetprotocol qtHaveModule(quick) { SUBDIRS += \ |