diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 0efe9428efbf4e3202c743780acb5a8c25421aaf..e5df5ed6a46636b42aa17a8e7338d3645e6a8f12 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -958,7 +958,8 @@ template <class EditorFactoryLike>
         inline EditorFactoryLike *findByKind(ExtensionSystem::PluginManager *pm,
                                              const QString &kind)
 {
-    foreach(EditorFactoryLike *efl, pm->template getObjects<EditorFactoryLike>())
+    const QList<EditorFactoryLike *> factories = pm->template getObjects<EditorFactoryLike>();
+    foreach(EditorFactoryLike *efl, factories)
         if (kind == efl->kind())
             return efl;
     return 0;