diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 494a5546313..b8c197cd0ca 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -81,6 +81,8 @@ #endif # define XSDEBUG(s) qDebug() << s +using namespace ProjectExplorer; + enum { MaxConnectionAttempts = 50, ConnectionAttemptDefaultInterval = 200 @@ -152,17 +154,16 @@ class QmlEnginePrivate { public: explicit QmlEnginePrivate(QmlEngine *q); - ~QmlEnginePrivate() { delete m_adapter; } private: friend class QmlEngine; int m_ping; - QmlAdapter *m_adapter; - ProjectExplorer::ApplicationLauncher m_applicationLauncher; + QmlAdapter m_adapter; + ApplicationLauncher m_applicationLauncher; }; QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q) - : m_ping(0), m_adapter(new QmlAdapter(q)) + : m_ping(0), m_adapter(q) {} @@ -198,12 +199,16 @@ void QmlEngine::setupInferior() if (startParameters().startMode == AttachToRemote) { requestRemoteSetup(); } else { - connect(&d->m_applicationLauncher, SIGNAL(processExited(int)), - SLOT(disconnected())); - connect(&d->m_applicationLauncher, SIGNAL(appendMessage(QString,ProjectExplorer::OutputFormat)), - SLOT(appendMessage(QString,ProjectExplorer::OutputFormat))); - connect(&d->m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)), - runControl(), SLOT(bringApplicationToForeground(qint64))); + connect(&d->m_applicationLauncher, + SIGNAL(processExited(int)), + SLOT(disconnected())); + connect(&d->m_applicationLauncher, + SIGNAL(appendMessage(QString,ProjectExplorer::OutputFormat)), + SLOT(appendMessage(QString,ProjectExplorer::OutputFormat))); + connect(&d->m_applicationLauncher, + SIGNAL(bringToForegroundRequested(qint64)), + runControl(), + SLOT(bringApplicationToForeground(qint64))); d->m_applicationLauncher.setEnvironment(startParameters().environment); d->m_applicationLauncher.setWorkingDirectory(startParameters().workingDirectory); @@ -212,7 +217,7 @@ void QmlEngine::setupInferior() } } -void QmlEngine::appendMessage(const QString &msg, ProjectExplorer::OutputFormat /* format */) +void QmlEngine::appendMessage(const QString &msg, OutputFormat /* format */) { showMessage(msg, AppStuff); // FIXME: Redirect to RunControl } @@ -223,7 +228,7 @@ void QmlEngine::connectionEstablished() ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); - pluginManager->addObject(d->m_adapter); + pluginManager->addObject(&d->m_adapter); pluginManager->addObject(this); showMessage(tr("QML Debugger connected."), StatusBar); @@ -243,11 +248,10 @@ void QmlEngine::connectionStartupFailed() void QmlEngine::connectionError(QAbstractSocket::SocketError socketError) { - if (socketError ==QAbstractSocket::RemoteHostClosedError) + if (socketError == QAbstractSocket::RemoteHostClosedError) showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar); } - void QmlEngine::serviceConnectionError(const QString &serviceName) { showMessage(tr("QML Debugger: Could not connect to service '%1'.") @@ -256,37 +260,37 @@ void QmlEngine::serviceConnectionError(const QString &serviceName) void QmlEngine::pauseConnection() { - d->m_adapter->pauseConnection(); + d->m_adapter.pauseConnection(); } void QmlEngine::closeConnection() { - ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); + ExtensionSystem::PluginManager *pluginManager = + ExtensionSystem::PluginManager::instance(); if (pluginManager->allObjects().contains(this)) { - disconnect(d->m_adapter, SIGNAL(connectionStartupFailed()), this, SLOT(connectionStartupFailed())); - d->m_adapter->closeConnection(); + disconnect(&d->m_adapter, SIGNAL(connectionStartupFailed()), + this, SLOT(connectionStartupFailed())); + d->m_adapter.closeConnection(); - pluginManager->removeObject(d->m_adapter); + pluginManager->removeObject(&d->m_adapter); pluginManager->removeObject(this); } } - void QmlEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); - if (!isSlaveEngine()) { + if (!isSlaveEngine()) startApplicationLauncher(); - } - d->m_adapter->beginConnection(); + d->m_adapter.beginConnection(); } void QmlEngine::startApplicationLauncher() { if (!d->m_applicationLauncher.isRunning()) { - d->m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui, + d->m_applicationLauncher.start(ApplicationLauncher::Gui, startParameters().executable, startParameters().processArgs); } @@ -337,15 +341,15 @@ void QmlEngine::shutdownEngine() void QmlEngine::setupEngine() { - d->m_adapter->setMaxConnectionAttempts(MaxConnectionAttempts); - d->m_adapter->setConnectionAttemptInterval(ConnectionAttemptDefaultInterval); - connect(d->m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)), + d->m_adapter.setMaxConnectionAttempts(MaxConnectionAttempts); + d->m_adapter.setConnectionAttemptInterval(ConnectionAttemptDefaultInterval); + connect(&d->m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)), SLOT(connectionError(QAbstractSocket::SocketError))); - connect(d->m_adapter, SIGNAL(serviceConnectionError(QString)), + connect(&d->m_adapter, SIGNAL(serviceConnectionError(QString)), SLOT(serviceConnectionError(QString))); - connect(d->m_adapter, SIGNAL(connected()), + connect(&d->m_adapter, SIGNAL(connected()), SLOT(connectionEstablished())); - connect(d->m_adapter, SIGNAL(connectionStartupFailed()), + connect(&d->m_adapter, SIGNAL(connectionStartupFailed()), SLOT(connectionStartupFailed())); notifyEngineSetupOk(); @@ -487,7 +491,8 @@ void QmlEngine::attemptBreakpointSynchronization() } QString processedFilename = handler->fileName(id); #ifdef Q_OS_MACX - // Qt Quick Applications by default copy the qml directory to buildDir()/X.app/Contents/Resources + // Qt Quick Applications by default copy the qml directory + // to buildDir()/X.app/Contents/Resources const QString applicationBundleDir = QFileInfo(startParameters().executable).absolutePath() + "/../.."; processedFilename = mangleFilenamePaths(handler->fileName(id), startParameters().projectDir, applicationBundleDir + "/Contents/Resources"); @@ -905,7 +910,8 @@ QString QmlEngine::fromShadowBuildFilename(const QString &filename) const QString importPath = qmlImportPath(); #ifdef Q_OS_MACX - // Qt Quick Applications by default copy the qml directory to buildDir()/X.app/Contents/Resources + // Qt Quick Applications by default copy the qml directory + // to buildDir()/X.app/Contents/Resources. const QString applicationBundleDir = QFileInfo(startParameters().executable).absolutePath() + "/../.."; newFilename = mangleFilenamePaths(newFilename, applicationBundleDir + "/Contents/Resources", startParameters().projectDir);