diff options
author | Daniel Teske <daniel.teske@digia.com> | 2014-07-29 13:32:24 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@digia.com> | 2014-07-29 16:25:35 +0200 |
commit | 677746cd820ea8baa400df6ea3546888d96ec462 (patch) | |
tree | 5e4425633d6da48e96239261379b194f6dee2b56 | |
parent | 3f4e966664eff0b53bad8a3681cdbbc3be2aa194 (diff) | |
download | qt-creator-677746cd820ea8baa400df6ea3546888d96ec462.tar.gz |
Android: Warn about broken gdbs on every platform
Add more indicators for a broken gdb. This also fixes a bug where the
message was errounously shown on non-OS X platforms
Task-number: QTCREATORBUG-12747
Change-Id: I7936e5eea58896aec382616d6e7236b8276f998d
Reviewed-by: hjk <hjk121@nokiamail.com>
-rw-r--r-- | src/plugins/android/androidsettingswidget.cpp | 102 | ||||
-rw-r--r-- | src/plugins/android/androidsettingswidget.h | 4 |
2 files changed, 58 insertions, 48 deletions
diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 6db4467442..59a84b87e6 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -136,6 +136,9 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) { m_ui->setupUi(this); + connect(&m_checkGdbWatcher, SIGNAL(finished()), + this, SLOT(checkGdbFinished())); + m_ui->SDKLocationPathChooser->setFileName(m_androidConfig.sdkLocation()); m_ui->SDKLocationPathChooser->setPromptDialogTitle(tr("Select Android SDK folder")); m_ui->NDKLocationPathChooser->setFileName(m_androidConfig.ndkLocation()); @@ -180,8 +183,6 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) connect(&m_futureWatcher, SIGNAL(finished()), this, SLOT(avdAdded())); - connect(&m_checkGdbWatcher, SIGNAL(finished()), - this, SLOT(checkGdbFinished())); } AndroidSettingsWidget::~AndroidSettingsWidget() @@ -191,38 +192,47 @@ AndroidSettingsWidget::~AndroidSettingsWidget() } // NOTE: Will be run via QFuture -static QPair<QString, bool> checkGdbForBrokenPython(const QString &path) -{ - QTime timer; - timer.start(); - QProcess proc; - proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(path); - proc.waitForStarted(); - - QByteArray output; - while (proc.waitForReadyRead(300)) { - output += proc.readAll(); - if (output.contains("(gdb)")) - break; - if (timer.elapsed() > 7 * 1000) - return qMakePair(path, false); // Took too long, abort - } +static QPair<QStringList, bool> checkGdbForBrokenPython(const QStringList &paths) +{ + foreach (const QString &path, paths) { + QTime timer; + timer.start(); + QProcess proc; + proc.setProcessChannelMode(QProcess::MergedChannels); + proc.start(path); + proc.waitForStarted(); + + QByteArray output; + while (proc.waitForReadyRead(300)) { + output += proc.readAll(); + if (output.contains("(gdb)")) + break; + if (timer.elapsed() > 7 * 1000) + return qMakePair(path, true); // Took too long, abort + } - output.clear(); + output.clear(); - proc.write("python import struct\n"); - proc.write("quit\n"); - while (proc.waitForFinished(300)) { - if (timer.elapsed() > 9 * 1000) - return qMakePair(path, false); // Took too long, abort - } - proc.waitForFinished(); + proc.write("python import string\n"); + proc.write("python print(string.ascii_uppercase)\n"); + proc.write("python import struct\n"); + proc.write("quit\n"); + while (proc.waitForFinished(300)) { + if (timer.elapsed() > 9 * 1000) + return qMakePair(path, true); // Took too long, abort + } + proc.waitForFinished(); - output = proc.readAll(); + output = proc.readAll(); - bool error = output.contains("_PyObject_Free") || output.contains("_PyExc_IOError"); - return qMakePair(path, error); + bool error = output.contains("_PyObject_Free") + || output.contains("_PyExc_IOError") + || output.contains("_sysconfigdata_nd ") + || !output.contains("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + if (error) + return qMakePair(paths, error); + } + return qMakePair(paths, false); } void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) @@ -240,6 +250,8 @@ void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) Utils::FileName platformPath = m_androidConfig.ndkLocation(); Utils::FileName toolChainPath = m_androidConfig.ndkLocation(); Utils::FileName sourcesPath = m_androidConfig.ndkLocation(); + m_ui->gdbWarningIconLabel->setVisible(false); + m_ui->gdbWarningLabel->setVisible(false); if (m_androidConfig.ndkLocation().isEmpty()) { m_ndkState = NotSet; } else if (!platformPath.appendPath(QLatin1String("platforms")).toFileInfo().exists() @@ -257,22 +269,20 @@ void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) m_ndkCompilerCount = compilerPaths.count(); // Check for a gdb with a broken python - if (Utils::HostOsInfo::isMacHost()) { - foreach (const AndroidToolChainFactory::AndroidToolChainInformation &ati, compilerPaths) { - // we only check the arm gdbs, that's indicative enough - if (ati.architecture != ProjectExplorer::Abi::ArmArchitecture) - continue; - Utils::FileName gdbPath = AndroidConfigurations::currentConfig().gdbPath(ati.architecture, ati.version); - if (gdbPath.toFileInfo().exists()) { - m_ui->gdbWarningIconLabel->setVisible(false); - m_ui->gdbWarningLabel->setVisible(false); - m_checkGdbWatcher.setFuture(QtConcurrent::run(&checkGdbForBrokenPython, gdbPath.toString())); - m_gdbCheckPath = gdbPath.toString(); - break; - } - } + QStringList gdbPaths; + foreach (const AndroidToolChainFactory::AndroidToolChainInformation &ati, compilerPaths) { + // we only check the arm gdbs, that's indicative enough + if (ati.architecture != ProjectExplorer::Abi::ArmArchitecture) + continue; + Utils::FileName gdbPath = m_androidConfig.gdbPath(ati.architecture, ati.version); + if (gdbPath.toFileInfo().exists()) + gdbPaths << gdbPath.toString(); } + if (!gdbPaths.isEmpty()) { + m_checkGdbWatcher.setFuture(QtConcurrent::run(&checkGdbForBrokenPython, gdbPaths)); + m_gdbCheckPaths = gdbPaths; + } // See if we have qt versions for those toolchains QSet<ProjectExplorer::Abi::Architecture> toolchainsForArch; @@ -569,8 +579,8 @@ void AndroidSettingsWidget::createKitToggled() void AndroidSettingsWidget::checkGdbFinished() { - QPair<QString, bool> result = m_checkGdbWatcher.future().result(); - if (result.first != m_gdbCheckPath) // no longer relevant + QPair<QStringList, bool> result = m_checkGdbWatcher.future().result(); + if (result.first != m_gdbCheckPaths) // no longer relevant return; m_ui->gdbWarningIconLabel->setVisible(result.second); m_ui->gdbWarningLabel->setVisible(result.second); diff --git a/src/plugins/android/androidsettingswidget.h b/src/plugins/android/androidsettingswidget.h index 2be6b1b522..8e7aaf5b89 100644 --- a/src/plugins/android/androidsettingswidget.h +++ b/src/plugins/android/androidsettingswidget.h @@ -114,8 +114,8 @@ private: AndroidConfig m_androidConfig; AvdModel m_AVDModel; QFutureWatcher<AndroidConfig::CreateAvdInfo> m_futureWatcher; - QFutureWatcher<QPair<QString, bool>> m_checkGdbWatcher; - QString m_gdbCheckPath; + QFutureWatcher<QPair<QStringList, bool>> m_checkGdbWatcher; + QStringList m_gdbCheckPaths; }; } // namespace Internal |