diff options
author | hjk <qthjk@ovi.com> | 2012-08-14 15:52:17 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-08-22 08:46:38 +0200 |
commit | 0e8ac9b6638d8f88f82d63a15531083363c520a7 (patch) | |
tree | 71d2c4d596535438ebc0ad085719947682a0de89 /src/plugins | |
parent | 90dae0252824d906a8a8eb2e9d3fbe12ab47a075 (diff) | |
download | qt-creator-0e8ac9b6638d8f88f82d63a15531083363c520a7.tar.gz |
android: simplify code, pull out common subexpressions
Change-Id: If3540328c0f2f0af375ccaba2e10c5417e8f1ed9
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/android/androiddebugsupport.cpp | 62 | ||||
-rw-r--r-- | src/plugins/android/androiddebugsupport.h | 7 |
2 files changed, 29 insertions, 40 deletions
diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 813fe11665..2fc5ac891d 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -62,31 +62,50 @@ static const char * const qMakeVariables[] = { "QT_INSTALL_IMPORTS" }; -static Qt4Project *project(AndroidRunConfiguration *rc) -{ return static_cast<Qt4Project *>(rc->target()->project()); } +static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion) +{ + if (!qtVersion) + return QStringList(); + + QSet<QString> paths; + for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) { + QString path = qtVersion->qmakeProperty(qMakeVariables[i]); + if (path.isNull()) + continue; + QDirIterator it(path, QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + paths.insert(it.fileInfo().absolutePath()); + } + } + return paths.toList(); +} RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig) { + Target *target = runConfig->target(); + Qt4Project *project = static_cast<Qt4Project *>(target->project()); + DebuggerStartParameters params; params.startMode = AttachToRemoteServer; - params.displayName = AndroidManager::packageName(runConfig->target()); + params.displayName = AndroidManager::packageName(target); params.remoteSetupNeeded = true; if (runConfig->debuggerAspect()->useCppDebugger()) { params.languages |= CppLanguage; - Profile *profile = runConfig->target()->profile(); + Profile *profile = target->profile(); params.sysRoot = SysRootProfileInformation::sysRoot(profile).toString(); params.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString(); if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile)) params.toolChainAbi = tc->targetAbi(); - params.executable = project(runConfig)->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process"); + params.executable = project->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process"); params.remoteChannel = runConfig->remoteChannel(); params.solibSearchPath.clear(); - QList<Qt4ProFileNode *> nodes = project(runConfig)->allProFiles(); + QList<Qt4ProFileNode *> nodes = project->allProFiles(); foreach (Qt4ProFileNode *node, nodes) if (node->projectType() == ApplicationTemplate) params.solibSearchPath.append(node->targetInformation().buildDir); - QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(runConfig->target()->profile()); + QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(profile); params.solibSearchPath.append(qtSoPaths(version)); } if (runConfig->debuggerAspect()->useQmlDebugger()) { @@ -94,9 +113,9 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration * params.qmlServerAddress = QLatin1String("localhost"); params.qmlServerPort = runConfig->debuggerAspect()->qmlDebugServerPort(); //TODO: Not sure if these are the right paths. - params.projectSourceDirectory = project(runConfig)->projectDirectory(); - params.projectSourceFiles = project(runConfig)->files(Qt4Project::ExcludeGeneratedFiles); - params.projectBuildDirectory = project(runConfig)->rootQt4ProjectNode()->buildDir(); + params.projectSourceDirectory = project->projectDirectory(); + params.projectSourceFiles = project->files(Qt4Project::ExcludeGeneratedFiles); + params.projectBuildDirectory = project->buildDir(); } DebuggerRunControl * const debuggerRunControl @@ -129,10 +148,6 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig, SLOT(handleRemoteOutput(QByteArray))); } -AndroidDebugSupport::~AndroidDebugSupport() -{ -} - void AndroidDebugSupport::handleRemoteProcessStarted(int gdbServerPort, int qmlPort) { disconnect(m_runner, SIGNAL(remoteProcessStarted(int,int)), @@ -167,24 +182,5 @@ void AndroidDebugSupport::handleRemoteErrorOutput(const QByteArray &output) } } -QStringList AndroidDebugSupport::qtSoPaths(QtSupport::BaseQtVersion *qtVersion) -{ - if (!qtVersion) - return QStringList(); - - QSet<QString> paths; - for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) { - QString path = qtVersion->qmakeProperty(qMakeVariables[i]); - if (path.isNull()) - continue; - QDirIterator it(path, QStringList() << QLatin1String("*.so"), QDir::Files, QDirIterator::Subdirectories); - while (it.hasNext()) { - it.next(); - paths.insert(it.fileInfo().absolutePath()); - } - } - return paths.toList(); -} - } // namespace Internal } // namespace Android diff --git a/src/plugins/android/androiddebugsupport.h b/src/plugins/android/androiddebugsupport.h index ed4048154b..7278272f12 100644 --- a/src/plugins/android/androiddebugsupport.h +++ b/src/plugins/android/androiddebugsupport.h @@ -33,10 +33,7 @@ #include "androidrunconfiguration.h" -#include <QObject> - namespace Debugger { class DebuggerRunControl; } -namespace QtSupport {class BaseQtVersion; } namespace ProjectExplorer { class RunControl; } namespace Android { @@ -54,7 +51,6 @@ public: AndroidDebugSupport(AndroidRunConfiguration *runConfig, Debugger::DebuggerRunControl *runControl); - ~AndroidDebugSupport(); private slots: void handleRemoteProcessStarted(int gdbServerPort = -1, int qmlPort = -1); @@ -64,9 +60,6 @@ private slots: void handleRemoteErrorOutput(const QByteArray &output); private: - static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion); - -private: Debugger::DebuggerRunControl* m_runControl; AndroidRunner * const m_runner; const QString m_dumperLib; |