diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
index 87f8e8f2d9d0c7cdd2b2028933247d690dd7c047..e56d7832b5efec5d183903876196b7b01628ec07 100644
--- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
+++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
@@ -299,7 +299,9 @@ QByteArray QmlStandaloneApp::generateMainCpp(const QString *errorMessage) const
         if (line.contains(QLatin1String("// MAINQML"))) {
             line = insertParameter(line, QLatin1Char('"') + path(MainQmlDeployed) + QLatin1Char('"'));
         } else if (line.contains(QLatin1String("// ADDIMPORTPATH"))) {
-            if (!m_modules.isEmpty())
+            if (m_modules.isEmpty())
+                continue;
+            else
                 line = insertParameter(line, QLatin1Char('"') + path(ModulesDir) + QLatin1Char('"'));
         } else if (line.contains(QLatin1String("// ORIENTATION"))) {
             if (m_orientation == Auto)