forked from qt-creator/qt-creator
Improved CDB autodetection.
Check for x32 as well; pop up a message box on failure.
This commit is contained in:
@@ -81,11 +81,11 @@ void CdbOptions::toSettings(QSettings *s) const
|
|||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CdbOptions::autoDetectPath(QString *outPath)
|
bool CdbOptions::autoDetectPath(QString *outPath, QStringList *checkedDirectories /* = 0 */)
|
||||||
{
|
{
|
||||||
// Look for $ProgramFiles/"Debugging Tools For Windows" and its
|
// Look for $ProgramFiles/"Debugging Tools For Windows" and its
|
||||||
// :" (x86)", " (x64)" variations
|
// :" (x86)", " (x64)" variations
|
||||||
static const char *postFixes[] = { " (x86)", " (x64)" };
|
static const char *postFixes[] = { " (x86)", " (x32)", " (x64)" };
|
||||||
|
|
||||||
outPath->clear();
|
outPath->clear();
|
||||||
const QByteArray programDirB = qgetenv("ProgramFiles");
|
const QByteArray programDirB = qgetenv("ProgramFiles");
|
||||||
@@ -95,6 +95,8 @@ bool CdbOptions::autoDetectPath(QString *outPath)
|
|||||||
const QString programDir = QString::fromLocal8Bit(programDirB) + QDir::separator();
|
const QString programDir = QString::fromLocal8Bit(programDirB) + QDir::separator();
|
||||||
const QString installDir = QLatin1String("Debugging Tools For Windows");
|
const QString installDir = QLatin1String("Debugging Tools For Windows");
|
||||||
QString path = programDir + installDir;
|
QString path = programDir + installDir;
|
||||||
|
if (checkedDirectories)
|
||||||
|
checkedDirectories->push_back(path);
|
||||||
if (QFileInfo(path).isDir()) {
|
if (QFileInfo(path).isDir()) {
|
||||||
*outPath = QDir::toNativeSeparators(path);
|
*outPath = QDir::toNativeSeparators(path);
|
||||||
return true;
|
return true;
|
||||||
@@ -103,6 +105,8 @@ bool CdbOptions::autoDetectPath(QString *outPath)
|
|||||||
for (int i = 0; i < sizeof(postFixes)/sizeof(const char*); i++) {
|
for (int i = 0; i < sizeof(postFixes)/sizeof(const char*); i++) {
|
||||||
path.truncate(rootLength);
|
path.truncate(rootLength);
|
||||||
path += QLatin1String(postFixes[i]);
|
path += QLatin1String(postFixes[i]);
|
||||||
|
if (checkedDirectories)
|
||||||
|
checkedDirectories->push_back(path);
|
||||||
if (QFileInfo(path).isDir()) {
|
if (QFileInfo(path).isDir()) {
|
||||||
*outPath = QDir::toNativeSeparators(path);
|
*outPath = QDir::toNativeSeparators(path);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
unsigned compare(const CdbOptions &s) const;
|
unsigned compare(const CdbOptions &s) const;
|
||||||
|
|
||||||
// Locate the debugging tools
|
// Locate the debugging tools
|
||||||
static bool autoDetectPath(QString *path);
|
static bool autoDetectPath(QString *path, QStringList *checkedDirectories = 0);
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
QString path;
|
QString path;
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
#include "debuggerconstants.h"
|
#include "debuggerconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
const char * const CDB_SETTINGS_ID = QT_TRANSLATE_NOOP("Debugger::Internal::CdbOptionsPageWidget", "Cdb");
|
const char * const CDB_SETTINGS_ID = QT_TRANSLATE_NOOP("Debugger::Internal::CdbOptionsPageWidget", "Cdb");
|
||||||
|
|
||||||
@@ -70,10 +72,18 @@ CdbOptions CdbOptionsPageWidget::options() const
|
|||||||
void CdbOptionsPageWidget::autoDetect()
|
void CdbOptionsPageWidget::autoDetect()
|
||||||
{
|
{
|
||||||
QString path;
|
QString path;
|
||||||
const bool ok = CdbOptions::autoDetectPath(&path);
|
QStringList checkedDirectories;
|
||||||
|
const bool ok = CdbOptions::autoDetectPath(&path, &checkedDirectories);
|
||||||
m_ui.cdbOptionsGroupBox->setChecked(ok);
|
m_ui.cdbOptionsGroupBox->setChecked(ok);
|
||||||
if (ok)
|
if (ok) {
|
||||||
m_ui.pathChooser->setPath(path);
|
m_ui.pathChooser->setPath(path);
|
||||||
|
} else {
|
||||||
|
const QString msg = tr("\"Debugging Tools for Windows\" could not be found.");
|
||||||
|
const QString details = tr("Checked:\n%1").arg(checkedDirectories.join(QString(QLatin1Char('\n'))));
|
||||||
|
QMessageBox msbBox(QMessageBox::Information, tr("Autodetection"), msg, QMessageBox::Ok, this);
|
||||||
|
msbBox.setDetailedText(details);
|
||||||
|
msbBox.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbOptionsPageWidget::setFailureMessage(const QString &msg)
|
void CdbOptionsPageWidget::setFailureMessage(const QString &msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user