forked from qt-creator/qt-creator
RemoteLinux: Move portsUsedByDebugger() to DebuggerRunConfigurationAspect
Change-Id: I0add29c3c69c4ba59cea159f32ca74be58bcee59 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -292,6 +292,16 @@ bool DebuggerRunConfigurationAspect::isQmlDebuggingSpinboxSuppressed() const
|
||||
return dev->canAutoDetectPorts();
|
||||
}
|
||||
|
||||
int DebuggerRunConfigurationAspect::portsUsedByDebugger() const
|
||||
{
|
||||
int ports = 0;
|
||||
if (useQmlDebugger())
|
||||
++ports;
|
||||
if (useCppDebugger())
|
||||
++ports;
|
||||
return ports;
|
||||
}
|
||||
|
||||
void DebuggerRunConfigurationAspect::toMap(QVariantMap &map) const
|
||||
{
|
||||
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), d.useCppDebugger == EnabledLanguage);
|
||||
|
@@ -74,6 +74,8 @@ public:
|
||||
void setUseMultiProcess(bool on);
|
||||
bool isQmlDebuggingSpinboxSuppressed() const;
|
||||
|
||||
int portsUsedByDebugger() const;
|
||||
|
||||
private:
|
||||
friend class Internal::DebuggerRunConfigWidget;
|
||||
DebuggerRunConfigurationAspectData d;
|
||||
|
@@ -105,14 +105,17 @@ bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id m
|
||||
return false;
|
||||
}
|
||||
|
||||
const QnxRunConfiguration * const rc = qobject_cast<QnxRunConfiguration *>(runConfiguration);
|
||||
const QnxDeviceConfiguration::ConstPtr dev = DeviceKitInformation::device(runConfiguration->target()->kit())
|
||||
.dynamicCast<const QnxDeviceConfiguration>();
|
||||
if (dev.isNull())
|
||||
return false;
|
||||
|
||||
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
|
||||
return rc->portsUsedByDebuggers() <= dev->freePorts().count();
|
||||
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|
||||
|| mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
|
||||
auto aspect = runConfiguration->extraAspect<DebuggerRunConfigurationAspect>();
|
||||
int portsUsed = aspect ? aspect->portsUsedByDebugger() : 0;
|
||||
return portsUsed <= dev->freePorts().count();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -41,17 +41,4 @@ AbstractRemoteLinuxRunConfiguration::AbstractRemoteLinuxRunConfiguration(Project
|
||||
|
||||
}
|
||||
|
||||
int AbstractRemoteLinuxRunConfiguration::portsUsedByDebuggers() const
|
||||
{
|
||||
int ports = 0;
|
||||
Debugger::DebuggerRunConfigurationAspect *aspect
|
||||
= extraAspect<Debugger::DebuggerRunConfigurationAspect>();
|
||||
if (aspect->useQmlDebugger())
|
||||
++ports;
|
||||
if (aspect->useCppDebugger())
|
||||
++ports;
|
||||
|
||||
return ports;
|
||||
}
|
||||
|
||||
} // namespace RemoteLinux
|
||||
|
@@ -48,8 +48,6 @@ public:
|
||||
virtual QString workingDirectory() const = 0;
|
||||
virtual Utils::Environment environment() const = 0;
|
||||
|
||||
int portsUsedByDebuggers() const;
|
||||
|
||||
protected:
|
||||
AbstractRemoteLinuxRunConfiguration(ProjectExplorer::Target *parent,
|
||||
AbstractRemoteLinuxRunConfiguration *source);
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "remotelinuxruncontrol.h"
|
||||
|
||||
#include <debugger/debuggerruncontrol.h>
|
||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||
#include <debugger/debuggerstartparameters.h>
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzerruncontrol.h>
|
||||
@@ -89,7 +90,10 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
|
||||
}
|
||||
auto * const rc = qobject_cast<AbstractRemoteLinuxRunConfiguration *>(runConfig);
|
||||
QTC_ASSERT(rc, return 0);
|
||||
if (rc->portsUsedByDebuggers() > dev->freePorts().count()) {
|
||||
|
||||
auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
|
||||
int portsUsed = aspect ? aspect->portsUsedByDebugger() : 0;
|
||||
if (portsUsed > dev->freePorts().count()) {
|
||||
*errorMessage = tr("Cannot debug: Not enough free ports available.");
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user