diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp
index 3211a8f35f44d050499848c9485cd255839f437d..78c8fad0c2db60b12f4876cbce98b9afcd312abb 100644
--- a/src/plugins/projectexplorer/target.cpp
+++ b/src/plugins/projectexplorer/target.cpp
@@ -551,15 +551,16 @@ void Target::updateDefaultDeployConfigurations()
         dcIds.append(dcFactory->availableCreationIds(this));
 
     QList<DeployConfiguration *> dcList = deployConfigurations();
+    QList<Core::Id> toCreate = dcIds;
 
     foreach (DeployConfiguration *dc, dcList) {
         if (dcIds.contains(dc->id()))
-            dcIds.removeOne(dc->id());
+            toCreate.removeOne(dc->id());
         else
             removeDeployConfiguration(dc);
     }
 
-    foreach (Core::Id id, dcIds) {
+    foreach (Core::Id id, toCreate) {
         foreach (DeployConfigurationFactory *dcFactory, dcFactories) {
             if (dcFactory->canCreate(this, id)) {
                 DeployConfiguration *dc = dcFactory->create(this, id);