Commit af8da5df authored by Daniel Teske's avatar Daniel Teske

Android: Create AVD: Show error messages

The check for errors was wrong and didn't even get the right string.
Fix that, and also use a QMessageBox for the errors.

Task-number: QTCREATORBUG-11729

Change-Id: I9aecd1dcbeabb35d60833419f7997ea4c704d65b
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent 29446504
......@@ -479,11 +479,19 @@ QString AndroidConfig::createAVD(QWidget *parent, int minApiLevel, QString targe
avdDialog.nameLineEdit->setValidator(&v);
if (d.exec() != QDialog::Accepted)
return QString();
return createAVD(avdDialog.targetComboBox->currentText(), avdDialog.nameLineEdit->text(),
avdDialog.abiComboBox->currentText(), avdDialog.sizeSpinBox->value());
QString error;
QString avd = createAVD(avdDialog.targetComboBox->currentText(), avdDialog.nameLineEdit->text(),
avdDialog.abiComboBox->currentText(), avdDialog.sizeSpinBox->value(),
&error);
if (!error.isEmpty()) {
QMessageBox::critical(parent, QApplication::translate("AndroidConfig", "Error Creating AVD"),
error);
}
return avd;
}
QString AndroidConfig::createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize) const
QString AndroidConfig::createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize, QString *error) const
{
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
......@@ -518,12 +526,16 @@ QString AndroidConfig::createAVD(const QString &target, const QString &name, con
break;
}
Core::MessageManager::write(QString::fromLocal8Bit(question), Core::MessageManager::Flash);
proc.waitForFinished();
if (proc.exitCode()) // error!
QString errorOutput = QString::fromLocal8Bit(proc.readAllStandardError());
// The exit code is always 0, so we need to check stderr
// For now assume that any output at all indicates a error
if (!errorOutput.isEmpty()) {
*error = errorOutput;
return QString();
}
return name;
}
......
......@@ -117,7 +117,7 @@ public:
QString createAVD(QWidget *parent, int minApiLevel = 0, QString targetArch = QString()) const;
QString createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize) const;
QString createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize, QString *error) const;
bool removeAVD(const QString &name) const;
QVector<AndroidDeviceInfo> connectedDevices(QString *error = 0) const;
......
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