diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp index 23c5716ff21c79aec2e528a1b4e5f031804a7b65..65e767b8d52ccbfdbabeeeb2bb4e894a7e0f0e37 100644 --- a/src/plugins/android/androiddevice.cpp +++ b/src/plugins/android/androiddevice.cpp @@ -104,9 +104,11 @@ IDevice::Ptr AndroidDevice::clone() const return IDevice::Ptr(new AndroidDevice(*this)); } -Connection AndroidDevice::toolControlChannel(const ControlChannelHint &) const +QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const { - return HostName("localhost"); + QUrl url; + url.setHost("localhost"); + return url; } } // namespace Internal diff --git a/src/plugins/android/androiddevice.h b/src/plugins/android/androiddevice.h index 3a59e29798106a0e3a5545226023c5e0a086f5e2..fc710ef3653d330b6d8b59137aa12d085f90e613 100644 --- a/src/plugins/android/androiddevice.h +++ b/src/plugins/android/androiddevice.h @@ -47,7 +47,7 @@ public: Utils::OsType osType() const override; ProjectExplorer::IDevice::Ptr clone() const override; - ProjectExplorer::Connection toolControlChannel(const ControlChannelHint &) const override; + QUrl toolControlChannel(const ControlChannelHint &) const override; protected: friend class AndroidDeviceFactory; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 72b69ab41b1ed31a2e650d4f3da005eec8254e1f..5c20d18166009f9ec2b5a37d48e1bafb5ca2c93a 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2179,9 +2179,8 @@ void DebuggerPluginPrivate::attachToQmlPort() if (device) { QSsh::SshConnectionParameters sshParameters = device->sshParameters(); rp.remoteChannel = QString("%1:%2").arg(sshParameters.host).arg(sshParameters.port); - Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel); - QTC_ASSERT(toolControl.is<HostName>(), return); - rp.qmlServer.host = toolControl.as<HostName>().host(); + QUrl toolControl = device->toolControlChannel(IDevice::QmlControlChannel); + rp.qmlServer.host = toolControl.host(); } rp.qmlServer.port = Utils::Port(dlg.port()); rp.startMode = AttachToRemoteProcess; diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index ecf4aa5a77cd97cc5ab3431f57bf53901c7093f3..23400d34c74f5da4b940582334894e01dfc9772b 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -382,7 +382,7 @@ IosQmlProfilerSupport::IosQmlProfilerSupport(RunControl *runControl) void IosQmlProfilerSupport::start() { - UrlConnection serverUrl; + QUrl serverUrl; QTcpServer server; QTC_ASSERT(server.listen(QHostAddress::LocalHost) || server.listen(QHostAddress::LocalHostIPv6), return); diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp index 3c494afd7d9673a99ea5422976d2faa5399d2c49..dde4edce5d2f2008ae58921106919428da640ded 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp @@ -137,9 +137,11 @@ DeviceEnvironmentFetcher::Ptr DesktopDevice::environmentFetcher() const return DeviceEnvironmentFetcher::Ptr(new DesktopDeviceEnvironmentFetcher()); } -Connection DesktopDevice::toolControlChannel(const ControlChannelHint &) const +QUrl DesktopDevice::toolControlChannel(const ControlChannelHint &) const { - return HostName("localhost"); + QUrl url; + url.setHost("localhost"); + return url; } Utils::OsType DesktopDevice::osType() const diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.h b/src/plugins/projectexplorer/devicesupport/desktopdevice.h index 80731edad3140a24679fffd9a234984f10bfbe09..588281c1d2b2a90a88ac9a90bbf1bb04b3ac19eb 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.h @@ -52,7 +52,7 @@ public: DeviceProcess *createProcess(QObject *parent) const override; DeviceProcessSignalOperation::Ptr signalOperation() const override; DeviceEnvironmentFetcher::Ptr environmentFetcher() const override; - Connection toolControlChannel(const ControlChannelHint &) const override; + QUrl toolControlChannel(const ControlChannelHint &) const override; Utils::OsType osType() const override; IDevice::Ptr clone() const override; diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index d4f0f87576ab6b5d2a96da3b57fa0ffc06a167be..4736e26e85e0d406142191b5603c7f9b68cf4b1a 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -411,9 +411,11 @@ void IDevice::setSshParameters(const QSsh::SshConnectionParameters &sshParameter d->sshParameters.hostKeyDatabase = DeviceManager::instance()->hostKeyDatabase(); } -Connection IDevice::toolControlChannel(const ControlChannelHint &) const +QUrl IDevice::toolControlChannel(const ControlChannelHint &) const { - return HostName(d->sshParameters.host); + QUrl url; + url.setHost(d->sshParameters.host); + return url; } void IDevice::setFreePorts(const Utils::PortList &freePorts) @@ -470,8 +472,4 @@ DeviceEnvironmentFetcher::DeviceEnvironmentFetcher() { } -void *HostName::staticTypeId = &HostName::staticTypeId; - -void *UrlConnection::staticTypeId = &UrlConnection::staticTypeId; - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 2f5270b7ea0a2c5a2bd1c90fec49314c10091e65..4bf9ed09c244c0521bac52b1c0eb3c0b440dcfe0 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -189,7 +189,7 @@ public: void setSshParameters(const QSsh::SshConnectionParameters &sshParameters); enum ControlChannelHint { QmlControlChannel }; - virtual Connection toolControlChannel(const ControlChannelHint &) const; + virtual QUrl toolControlChannel(const ControlChannelHint &) const; Utils::PortList freePorts() const; void setFreePorts(const Utils::PortList &freePorts); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index dac32dc2376bd760f420ad0b2fbfa360717ee07d..48f7a78a8e8b084dd1f409ae02e165148b7b3e3f 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -688,7 +688,6 @@ public: QString displayName; Runnable runnable; IDevice::ConstPtr device; - Connection connection; Core::Id runMode; Utils::Icon icon; const QPointer<RunConfiguration> runConfiguration; // Not owned. @@ -985,16 +984,6 @@ void RunControl::setRunnable(const Runnable &runnable) d->runnable = runnable; } -const Connection &RunControl::connection() const -{ - return d->connection; -} - -void RunControl::setConnection(const Connection &connection) -{ - d->connection = connection; -} - QString RunControl::displayName() const { return d->displayName; @@ -1492,11 +1481,6 @@ const Runnable &RunWorker::runnable() const return d->runControl->runnable(); } -const Connection &RunWorker::connection() const -{ - return d->runControl->connection(); -} - Core::Id RunWorker::runMode() const { return d->runControl->runMode(); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index e4e726e25f3530c74248dacaa125eda9ca236da4..e1eef5bd68e0708b1d3449a6f80edeabc1b7356f 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -198,44 +198,6 @@ private: std::unique_ptr<Concept> d; }; -class PROJECTEXPLORER_EXPORT Connection -{ - struct Concept - { - virtual ~Concept() {} - virtual Concept *clone() const = 0; - virtual void *typeId() const = 0; - }; - - template <class T> - struct Model : public Concept - { - Model(const T &data) : m_data(data) { } - Concept *clone() const override { return new Model(*this); } - void *typeId() const override { return T::staticTypeId; } - T m_data; - }; - -public: - Connection() = default; - Connection(const Connection &other) : d(other.d ? other.d->clone() : nullptr) { } - Connection(Connection &&other) /* MSVC 2013 doesn't want = default */ : d(std::move(other.d)) {} - template <class T> Connection(const T &data) : d(new Model<T>(data)) {} - - void operator=(Connection other) { d = std::move(other.d); } - - template <class T> bool is() const { - return d.get() && (d.get()->typeId() == T::staticTypeId); - } - - template <class T> const T &as() const { - return static_cast<Model<T> *>(d.get())->m_data; - } - -private: - std::unique_ptr<Concept> d; -}; - // Documentation inside. class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration { @@ -387,7 +349,6 @@ public: void appendMessage(const QString &msg, Utils::OutputFormat format); IDevice::ConstPtr device() const; const Runnable &runnable() const; - const Connection &connection() const; Core::Id runMode() const; // States @@ -466,9 +427,6 @@ public: const Runnable &runnable() const; void setRunnable(const Runnable &runnable); - const Connection &connection() const; - void setConnection(const Connection &connection); - virtual void appendMessage(const QString &msg, Utils::OutputFormat format); virtual void bringApplicationToForeground(); diff --git a/src/plugins/projectexplorer/runnables.cpp b/src/plugins/projectexplorer/runnables.cpp index 2a6bf23d6cf3d0a2656c046b9fb7f7b1afc8958d..3ac15f53ef715f839fab715f981bf1308a371f71 100644 --- a/src/plugins/projectexplorer/runnables.cpp +++ b/src/plugins/projectexplorer/runnables.cpp @@ -41,22 +41,8 @@ bool operator==(const StandardRunnable &r1, const StandardRunnable &r2) void *StandardRunnable::staticTypeId = &StandardRunnable::staticTypeId; -UrlConnection UrlConnection::fromHost(const QString &host) -{ - UrlConnection connection; - connection.setHost(host); - return connection; -} - -UrlConnection UrlConnection::localHostWithoutPort() -{ - QUrl serverUrl; - QTcpServer server; - serverUrl.setHost(server.serverAddress().toString()); - return UrlConnection(serverUrl); -} -UrlConnection UrlConnection::localHostAndFreePort() +QUrl urlFromLocalHostAndFreePort() { QUrl serverUrl; QTcpServer server; @@ -64,17 +50,22 @@ UrlConnection UrlConnection::localHostAndFreePort() serverUrl.setHost(server.serverAddress().toString()); serverUrl.setPort(server.serverPort()); } - return UrlConnection(serverUrl); + return serverUrl; } -UrlConnection UrlConnection::localSocket() +QUrl urlFromLocalSocket() { QUrl serverUrl; - serverUrl.setScheme(socketScheme()); + serverUrl.setScheme(urlSocketScheme()); Utils::TemporaryFile file("qmlprofiler-freesocket"); if (file.open()) serverUrl.setPath(file.fileName()); - return UrlConnection(serverUrl); + return serverUrl; +} + +QString urlSocketScheme() +{ + return QString("socket"); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 09c06e7754e7238deb174de5d0aeb1dd8724565d..f28aefeda4b3bb6593debd10038940eb1dc954e4 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -53,32 +53,8 @@ public: PROJECTEXPLORER_EXPORT bool operator==(const StandardRunnable &r1, const StandardRunnable &r2); -class PROJECTEXPLORER_EXPORT HostName -{ -public: - explicit HostName(const QString &host) : m_host(host) {} - QString host() const { return m_host; } - - static void *staticTypeId; - -private: - QString m_host; -}; - -class PROJECTEXPLORER_EXPORT UrlConnection : public QUrl -{ -public: - UrlConnection() {} - explicit UrlConnection(const QUrl &url) : QUrl(url) {} - - static UrlConnection fromHost(const QString &host); - static UrlConnection localHostAndFreePort(); - static UrlConnection localHostWithoutPort(); - static UrlConnection localSocket(); - - static QString socketScheme() { return QLatin1String("socket"); } - - static void *staticTypeId; -}; +PROJECTEXPLORER_EXPORT QUrl urlFromLocalHostAndFreePort(); +PROJECTEXPLORER_EXPORT QUrl urlFromLocalSocket(); +PROJECTEXPLORER_EXPORT QString urlSocketScheme(); } // namespace ProjectExplorer diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp index f1dd71224f30f37e1214cd25a1d84e0627690ca2..0f5c0376cb3042c323bb07ab31b6cbeacc86f365 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp @@ -271,10 +271,7 @@ void QmlProfilerRunner::setServerUrl(const QUrl &serverUrl) QUrl QmlProfilerRunner::serverUrl() const { QVariant recordedServer = recordedData(QmlServerUrl); - if (recordedServer.isValid()) - return recordedServer.toUrl(); - QTC_ASSERT(connection().is<UrlConnection>(), return QUrl()); - return connection().as<UrlConnection>(); + return recordedServer.toUrl(); } // @@ -289,12 +286,12 @@ static QUrl localServerUrl(RunControl *runControl) const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); if (version) { if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0)) - serverUrl = UrlConnection::localSocket(); + serverUrl = urlFromLocalSocket(); else - serverUrl = UrlConnection::localHostAndFreePort(); + serverUrl = urlFromLocalHostAndFreePort(); } else { qWarning("Running QML profiler on Kit without Qt version?"); - serverUrl = UrlConnection::localHostAndFreePort(); + serverUrl = urlFromLocalHostAndFreePort(); } return serverUrl; } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 8a655b955c68cc72602014da91615a26b154497b..de6e744d5da7c25a6e20d936ae96d2a2f8a18126 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -580,9 +580,8 @@ void QmlProfilerTool::attachToWaitingApplication() IDevice::ConstPtr device = DeviceKitInformation::device(kit); QTC_ASSERT(device, return); - Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel); - QTC_ASSERT(toolControl.is<HostName>(), return); - serverUrl.setHost(toolControl.as<HostName>().host()); + QUrl toolControl = device->toolControlChannel(IDevice::QmlControlChannel); + serverUrl.setHost(toolControl.host()); serverUrl.setPort(port); Debugger::selectPerspective(Constants::QmlProfilerPerspectiveId); diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 5d776965745cb37da73136774f2d25ef76edb51d..21bddf6f3321fa9698c0c083fec5af482a66a6f5 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -80,7 +80,7 @@ void LocalQmlProfilerRunnerTest::testRunner1() QTRY_COMPARE_WITH_TIMEOUT(runCount, 1, 10000); QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); - serverUrl = UrlConnection::localSocket(); + serverUrl = urlFromLocalSocket(); debuggee.executable = QCoreApplication::applicationFilePath(); // comma is used to specify a test function. In this case, an invalid one. @@ -97,7 +97,7 @@ void LocalQmlProfilerRunnerTest::testRunner2() QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); debuggee.commandLineArguments.clear(); - serverUrl = UrlConnection::localHostAndFreePort(); + serverUrl = urlFromLocalHostAndFreePort(); start(); @@ -119,7 +119,7 @@ void LocalQmlProfilerRunnerTest::testRunner4() void LocalQmlProfilerRunnerTest::testFindFreePort() { - QUrl serverUrl = UrlConnection::localHostAndFreePort(); + QUrl serverUrl = urlFromLocalHostAndFreePort(); QVERIFY(serverUrl.port() != -1); QVERIFY(!serverUrl.host().isEmpty()); QTcpServer server; @@ -128,7 +128,7 @@ void LocalQmlProfilerRunnerTest::testFindFreePort() void LocalQmlProfilerRunnerTest::testFindFreeSocket() { - QUrl serverUrl = UrlConnection::localSocket(); + QUrl serverUrl = urlFromLocalSocket(); QString socket = serverUrl.path(); QVERIFY(!socket.isEmpty()); QVERIFY(!QFile::exists(socket)); diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h index 35bae9faeb5cfa52152526a5312347df1da2f584..7b6bc60980e8a2ab07bc2c1d84d012f5e88f9ad1 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.h @@ -55,7 +55,7 @@ private: int runCount = 0; ProjectExplorer::RunControl *runControl = nullptr; ProjectExplorer::StandardRunnable debuggee; - ProjectExplorer::UrlConnection serverUrl; + QUrl serverUrl; }; } // namespace Internal diff --git a/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp index 3dab1be2c01662c36f7aa98751f8bee593476ea5..d2347d42640989a091a363cea8a74a1a435f31b3 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilerclientmanager_test.cpp @@ -70,12 +70,12 @@ void QmlProfilerClientManagerTest::testConnectionFailure_data() QTest::addColumn<QmlProfilerStateManager *>("stateManager"); QVarLengthArray<QmlProfilerStateManager *> stateManagers({nullptr, &stateManager}); - QUrl localUrl = UrlConnection::localHostAndFreePort(); + QUrl localUrl = urlFromLocalHostAndFreePort(); QTest::addColumn<QUrl>("serverUrl"); QVarLengthArray<QString> hosts({"", "/-/|\\-\\|/-", localUrl.host()}); QVarLengthArray<int> ports({-1, 5, localUrl.port()}); - QVarLengthArray<QString> sockets({"", "/-/|\\-\\|/-", UrlConnection::localSocket().path()}); + QVarLengthArray<QString> sockets({"", "/-/|\\-\\|/-", urlFromLocalSocket().path()}); foreach (QmlProfilerModelManager *modelManager, modelManagers) { foreach (QmlProfilerStateManager *stateManager, stateManagers) { @@ -101,7 +101,7 @@ void QmlProfilerClientManagerTest::testConnectionFailure_data() .arg(0) .arg(socket); QUrl url; - url.setScheme(ProjectExplorer::UrlConnection::socketScheme()); + url.setScheme(urlSocketScheme()); url.setPath(socket); QTest::newRow(tag.toLatin1().constData()) << modelManager << stateManager << url; } @@ -175,7 +175,7 @@ void QmlProfilerClientManagerTest::testUnresponsiveTcp() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QUrl serverUrl = UrlConnection::localHostAndFreePort(); + QUrl serverUrl = urlFromLocalHostAndFreePort(); QTcpServer server; server.listen(QHostAddress(serverUrl.host()), serverUrl.port()); @@ -204,7 +204,7 @@ void QmlProfilerClientManagerTest::testUnresponsiveLocal() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QUrl socketUrl = UrlConnection::localSocket(); + QUrl socketUrl = urlFromLocalSocket(); QLocalSocket socket; QSignalSpy connectionSpy(&socket, SIGNAL(connected())); @@ -256,7 +256,7 @@ void QmlProfilerClientManagerTest::testResponsiveTcp() { QFETCH(quint32, flushInterval); - QUrl serverUrl = UrlConnection::localHostAndFreePort(); + QUrl serverUrl = urlFromLocalHostAndFreePort(); QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened())); QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed())); @@ -315,7 +315,7 @@ void QmlProfilerClientManagerTest::testResponsiveLocal() { QFETCH(quint32, flushInterval); - QUrl socketUrl = UrlConnection::localSocket(); + QUrl socketUrl = urlFromLocalSocket(); QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened())); QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed())); @@ -380,7 +380,7 @@ void QmlProfilerClientManagerTest::testInvalidData() clientManager.setProfilerStateManager(&stateManager); clientManager.setModelManager(&modelManager); - QUrl serverUrl = UrlConnection::localHostAndFreePort(); + QUrl serverUrl = urlFromLocalHostAndFreePort(); bool dataSent = false; QTcpServer server; @@ -411,7 +411,7 @@ void QmlProfilerClientManagerTest::testInvalidData() void QmlProfilerClientManagerTest::testStopRecording() { - QUrl socketUrl = UrlConnection::localSocket(); + QUrl socketUrl = urlFromLocalSocket(); { QmlProfilerClientManager clientManager;