diff options
author | Daniel Teske <daniel.teske@digia.com> | 2014-04-11 13:31:01 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@digia.com> | 2014-05-08 11:03:38 +0200 |
commit | 7a91287c803eb2cf6b340b34034c33fd64a611aa (patch) | |
tree | 7452bb8c40412eecabee2dad82a8a7859fed9f86 /src/plugins/android/androidsettingswidget.cpp | |
parent | acfe2a2771fa2b392709471eeb0a3e36f3cd775b (diff) | |
download | qt-creator-7a91287c803eb2cf6b340b34034c33fd64a611aa.tar.gz |
Android: Fix blocking the ui on adding an avd
Task-number: QTCREATORBUG-10601
Change-Id: I3d1fef8a44f434f7eb484f538863c436b4e3a21c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/android/androidsettingswidget.cpp')
-rw-r--r-- | src/plugins/android/androidsettingswidget.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index e60357a37f..5c6b6fe751 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -53,6 +53,7 @@ #include <QMessageBox> #include <QModelIndex> #include <QtCore/QUrl> +#include <QtConcurrentRun> namespace Android { namespace Internal { @@ -64,6 +65,15 @@ void AvdModel::setAvdList(const QVector<AndroidDeviceInfo> &list) endResetModel(); } +QModelIndex AvdModel::indexForAvdName(const QString &avdName) const +{ + for (int i = 0; i < m_list.size(); ++i) { + if (m_list.at(i).serialNumber == avdName) + return index(i, 0); + } + return QModelIndex(); +} + QString AvdModel::avdName(const QModelIndex &index) const { return m_list.at(index.row()).serialNumber; @@ -144,11 +154,15 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent) check(All); applyToUi(All); + + connect(&m_futureWatcher, SIGNAL(finished()), + this, SLOT(avdAdded())); } AndroidSettingsWidget::~AndroidSettingsWidget() { delete m_ui; + m_futureWatcher.waitForFinished(); } void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode) @@ -468,9 +482,28 @@ void AndroidSettingsWidget::openOpenJDKDownloadUrl() void AndroidSettingsWidget::addAVD() { - m_androidConfig.createAVD(this); + m_ui->AVDAddPushButton->setEnabled(false); + AndroidConfig::CreateAvdInfo info = m_androidConfig.gatherCreateAVDInfo(this); + + if (info.target.isEmpty()) { + m_ui->AVDAddPushButton->setEnabled(true); + return; + } + + m_futureWatcher.setFuture(m_androidConfig.createAVD(info)); +} + +void AndroidSettingsWidget::avdAdded() +{ + m_ui->AVDAddPushButton->setEnabled(true); + AndroidConfig::CreateAvdInfo info = m_futureWatcher.result(); + if (!info.error.isEmpty()) { + QMessageBox::critical(this, QApplication::translate("AndroidConfig", "Error Creating AVD"), info.error); + return; + } + m_AVDModel.setAvdList(m_androidConfig.androidVirtualDevices()); - avdActivated(m_ui->AVDTableView->currentIndex()); + m_ui->AVDTableView->setCurrentIndex(m_AVDModel.indexForAvdName(info.name)); } void AndroidSettingsWidget::removeAVD() |