summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@theqtcompany.com>2015-01-20 12:43:46 +0100
committerDaniel Teske <daniel.teske@theqtcompany.com>2015-01-20 16:24:26 +0100
commit64cc15bca4f6e91917dea28387c39706a40805f3 (patch)
treefdde562034e9155e3c2a7f55cc1cb3ed4ea1ca28
parent8211a849e1c754a976574ec66316b26e8f1f1da9 (diff)
downloadqt-creator-64cc15bca4f6e91917dea28387c39706a40805f3.tar.gz
Kit: Fix crash on removing android kits that were autodetected
To reproduce: In the Android settings, enabled "Automatically create kits" -> This creates kits with autodetected set to true Switch to the kits page to get the KitPage filled, those kits now appear under the autodetected node. Switch to the Android settings and disable "Automatically create kits", -> This doesn't want to delete the old kits, to not throw away user settings, so the kits are marked as manual by calling setAutoDetected Switch to the Kit page and notice the kits still listed under the autodetected node. Clicking apply enables the remove button and on removing Creator crashes. Add the necessary signal emissions to setAutoDetected and several other methods and fix the KitModel to cope with changes to autodetected. Task-number: QTCREATORBUG-13736 Change-Id: I3d0ff247a6bfff8ace53df8535749db5c736d54b Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
-rw-r--r--src/plugins/projectexplorer/kit.cpp6
-rw-r--r--src/plugins/projectexplorer/kitmanagerconfigwidget.cpp5
-rw-r--r--src/plugins/projectexplorer/kitmanagerconfigwidget.h1
-rw-r--r--src/plugins/projectexplorer/kitmodel.cpp28
-rw-r--r--src/plugins/projectexplorer/kitmodel.h1
5 files changed, 40 insertions, 1 deletions
diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp
index 7fae069f36..b1247fd2eb 100644
--- a/src/plugins/projectexplorer/kit.cpp
+++ b/src/plugins/projectexplorer/kit.cpp
@@ -582,16 +582,19 @@ QString Kit::toHtml(const QList<Task> &additional) const
void Kit::setAutoDetected(bool detected)
{
d->m_autodetected = detected;
+ kitUpdated();
}
void Kit::setAutoDetectionSource(const QString &autoDetectionSource)
{
d->m_autoDetectionSource = autoDetectionSource;
+ kitUpdated();
}
void Kit::setSdkProvided(bool sdkProvided)
{
d->m_sdkProvided = sdkProvided;
+ kitUpdated();
}
void Kit::makeSticky()
@@ -608,11 +611,13 @@ void Kit::setSticky(Core::Id id, bool b)
d->m_sticky.insert(id);
else
d->m_sticky.remove(id);
+ kitUpdated();
}
void Kit::makeUnSticky()
{
d->m_sticky.clear();
+ kitUpdated();
}
void Kit::setMutable(Id id, bool b)
@@ -621,6 +626,7 @@ void Kit::setMutable(Id id, bool b)
d->m_mutable.insert(id);
else
d->m_mutable.remove(id);
+ kitUpdated();
}
bool Kit::isMutable(Id id) const
diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp
index 408a567aa7..375b0fb393 100644
--- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp
+++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp
@@ -354,8 +354,11 @@ void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
void KitManagerConfigWidget::kitWasUpdated(Kit *k)
{
- if (m_kit == k)
+ if (m_kit == k) {
+ bool emitSignal = m_kit->isAutoDetected() != m_modifiedKit->isAutoDetected();
discard();
+ emit isAutoDetectedChanged();
+ }
updateVisibility();
}
diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.h b/src/plugins/projectexplorer/kitmanagerconfigwidget.h
index 28879d9767..750ed14eab 100644
--- a/src/plugins/projectexplorer/kitmanagerconfigwidget.h
+++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.h
@@ -77,6 +77,7 @@ public:
signals:
void dirty();
+ void isAutoDetectedChanged();
private slots:
void setIcon();
diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp
index f484be8558..69df6f362e 100644
--- a/src/plugins/projectexplorer/kitmodel.cpp
+++ b/src/plugins/projectexplorer/kitmodel.cpp
@@ -279,6 +279,31 @@ void KitModel::setDirty()
}
}
+void KitModel::isAutoDetectedChanged()
+{
+ KitManagerConfigWidget *w = qobject_cast<KitManagerConfigWidget *>(sender());
+ int idx = -1;
+ idx = Utils::indexOf(m_manualRoot->childNodes, [w](KitNode *node) { return node->widget == w; });
+ KitNode *oldParent = 0;
+ KitNode *newParent = w->workingCopy()->isAutoDetected() ? m_autoRoot : m_manualRoot;
+ if (idx != -1) {
+ oldParent = m_manualRoot;
+ } else {
+ idx = Utils::indexOf(m_autoRoot->childNodes, [w](KitNode *node) { return node->widget == w; });
+ if (idx != -1) {
+ oldParent = m_autoRoot;
+ }
+ }
+
+ if (oldParent && oldParent != newParent) {
+ beginMoveRows(index(oldParent), idx, idx, index(newParent), newParent->childNodes.size());
+ KitNode *n = oldParent->childNodes.takeAt(idx);
+ n->parent = newParent;
+ newParent->childNodes.append(n);
+ endMoveRows();
+ }
+}
+
void KitModel::validateKitNames()
{
QList<KitNode *> nodes = m_manualRoot->childNodes;
@@ -395,6 +420,9 @@ KitNode *KitModel::createNode(KitNode *parent, Kit *k)
KitNode *node = new KitNode(parent, k);
m_parentLayout->addWidget(node->widget);
connect(node->widget, SIGNAL(dirty()), this, SLOT(setDirty()));
+ connect(node->widget, SIGNAL(isAutoDetectedChanged()),
+ this, SLOT(isAutoDetectedChanged()));
+
return node;
}
diff --git a/src/plugins/projectexplorer/kitmodel.h b/src/plugins/projectexplorer/kitmodel.h
index 2cde469b3f..772a5ed383 100644
--- a/src/plugins/projectexplorer/kitmodel.h
+++ b/src/plugins/projectexplorer/kitmodel.h
@@ -97,6 +97,7 @@ private slots:
void changeDefaultKit();
void setDirty();
void validateKitNames();
+ void isAutoDetectedChanged();
private:
QModelIndex index(KitNode *, int column = 0) const;