Commit ac9458e6 authored by hjk's avatar hjk
Browse files

debugger: move qtInstallPath closer to place where it is used



Change-Id: I6ed602a7cf498d56fa79cef72aebe7742bc50075
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent bab670af
......@@ -2641,8 +2641,6 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
<< ')';
str << '\n';
}
if (!sp.qtInstallPath.isEmpty())
str << "Qt: " << QDir::toNativeSeparators(sp.qtInstallPath) << '\n';
if (!sp.qmlServerAddress.isEmpty())
str << "QML server: " << sp.qmlServerAddress << ':'
<< sp.qmlServerPort << '\n';
......
......@@ -64,7 +64,6 @@
#include <utils/qtcprocess.h>
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <utils/buildablehelperlibrary.h>
#include <QDir>
#include <QCheckBox>
......@@ -897,17 +896,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
sp.dumperLibraryLocations = rc->dumperLibraryLocations();
if (target) {
if (QByteArray(target->metaObject()->className()).contains("Qt4")) {
// FIXME: Get this from the profile?
// We could query the QtVersion for this information directly, but then we
// will need to add a dependency on QtSupport to the debugger.
//
// The profile could also get a method to extract the required information from
// its information to avoid this dependecy (as we do for the environment).
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment);
if (!qmake.isEmpty())
sp.qtInstallPath = findQtInstallPath(qmake);
}
if (const Project *project = target->project()) {
sp.projectSourceDirectory = project->projectDirectory();
if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
......
......@@ -29,9 +29,12 @@
**************************************************************************/
#include "debuggersourcepathmappingwidget.h"
#include "debuggerstartparameters.h"
#include <utils/buildablehelperlibrary.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <QVBoxLayout>
#include <QHBoxLayout>
......@@ -48,11 +51,11 @@
#include <QDir>
#include <QPair>
using namespace Utils;
// Qt's various build paths for unpatched versions.
#if defined(Q_OS_WIN)
static const char* qtBuildPaths[] = {
"C:/qt-greenhouse/Trolltech/Code_less_create_more/"
"Trolltech/Code_less_create_more/Troll/4.6/qt",
"C:/iwmake/build_mingw_opensource",
"C:/ndk_buildrepos/qt-desktop/src"};
#elif defined(Q_OS_MAC)
......@@ -206,7 +209,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent
m_addQtButton(new QPushButton(tr("Add Qt sources..."), this)),
m_removeButton(new QPushButton(tr("Remove"), this)),
m_sourceLineEdit(new QLineEdit(this)),
m_targetChooser(new Utils::PathChooser(this))
m_targetChooser(new PathChooser(this))
{
setTitle(tr("Source Paths Mapping"));
setToolTip(tr("<html><head/><body><p>Mappings of source file folders to "
......@@ -245,7 +248,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent
treeHLayout->addLayout(buttonLayout);
// Edit part
m_targetChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
m_targetChooser->setExpectedKind(PathChooser::ExistingDirectory);
connect(m_sourceLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(slotEditSourceFieldChanged()));
connect(m_targetChooser, SIGNAL(changed(QString)),
......@@ -390,12 +393,52 @@ void DebuggerSourcePathMappingWidget::slotEditTargetFieldChanged()
}
}
// Find Qt installation by running qmake
static QString findQtInstallPath(const FileName &qmakePath)
{
if (qmakePath.isEmpty())
return QString();
QProcess proc;
QStringList args;
args.append(QLatin1String("-query"));
args.append(QLatin1String("QT_INSTALL_HEADERS"));
proc.start(qmakePath.toString(), args);
if (!proc.waitForStarted()) {
qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(qmakePath.toString()),
qPrintable(proc.errorString()));
return QString();
}
proc.closeWriteChannel();
if (!proc.waitForFinished()) {
SynchronousProcess::stopProcess(proc);
qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
return QString();
}
if (proc.exitStatus() != QProcess::NormalExit) {
qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
return QString();
}
const QByteArray ba = proc.readAllStandardOutput().trimmed();
QDir dir(QString::fromLocal8Bit(ba));
if (dir.exists() && dir.cdUp())
return dir.absolutePath();
return QString();
}
/* Merge settings for an installed Qt (unless another setting
* is already in the map. */
DebuggerSourcePathMappingWidget::SourcePathMap
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const QString &qtInstallPath,
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerStartParameters &sp,
const SourcePathMap &in)
{
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment);
// FIXME: Get this from the profile?
// We could query the QtVersion for this information directly, but then we
// will need to add a dependency on QtSupport to the debugger.
//
// The profile could also get a method to extract the required information from
// its information to avoid this dependency (as we do for the environment).
const QString qtInstallPath = findQtInstallPath(qmake);
SourcePathMap rc = in;
const size_t buildPathCount = sizeof(qtBuildPaths)/sizeof(const char *);
if (qtInstallPath.isEmpty() || buildPathCount == 0)
......
......@@ -44,17 +44,20 @@ class QLineEdit;
class QModelIndex;
QT_END_NAMESPACE
namespace Utils {
class PathChooser;
}
namespace Utils { class PathChooser; }
namespace Debugger {
class DebuggerStartParameters;
namespace Internal {
class SourcePathMappingModel;
class DebuggerSourcePathMappingWidget : public QGroupBox
{
Q_OBJECT
public:
typedef QMap<QString, QString> SourcePathMap;
......@@ -65,11 +68,9 @@ public:
/* Merge settings for an installed Qt (unless another setting
* is already in the map. */
static SourcePathMap mergePlatformQtPath(const QString &qtInstallPath,
static SourcePathMap mergePlatformQtPath(const DebuggerStartParameters &sp,
const SourcePathMap &in);
signals:
private slots:
void slotAdd();
void slotAddQt();
......
......@@ -107,14 +107,11 @@ public:
QString projectBuildDirectory;
QStringList projectSourceFiles;
QString qtInstallPath;
// Used by remote debugging.
QString remoteChannel;
QString symbolFileName;
bool useServerStartScript;
QString serverStartScript;
//QString sysroot;
QString searchPath; // Gdb "set solib-search-path"
QString debugInfoLocation; // Gdb "set-debug-file-directory".
QStringList debugSourceLocation; // Gdb "directory"
......@@ -125,9 +122,6 @@ public:
QSsh::SshConnectionParameters connParams;
bool remoteSetupNeeded;
//QString debuggerCommand;
//ProjectExplorer::Abi toolChainAbi;
QString dumperLibrary;
QStringList solibSearchPath;
QStringList dumperLibraryLocations;
......
......@@ -4797,8 +4797,9 @@ void GdbEngine::startGdb(const QStringList &args)
modulesHandler()->updateModule(module);
// Apply source path mappings from global options.
//showMessage(_("Assuming Qt is installed at %1").arg(qtInstallPath));
const SourcePathMap sourcePathMap =
DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp.qtInstallPath,
DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp,
debuggerCore()->globalDebuggerOptions()->sourcePathMap);
const SourcePathMapIterator cend = sourcePathMap.constEnd();
SourcePathMapIterator it = sourcePathMap.constBegin();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment