QTfrontend/model/gameSchemeModel.cpp
changeset 13853 46e1c1069ac2
parent 13554 a5a8488e2485
child 14269 47af42f7ca8b
--- a/QTfrontend/model/gameSchemeModel.cpp	Fri Oct 05 19:25:14 2018 +0200
+++ b/QTfrontend/model/gameSchemeModel.cpp	Fri Oct 05 19:37:06 2018 +0200
@@ -738,6 +738,11 @@
     if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) {
         QDir().mkdir(cfgdir->absolutePath() + "/Schemes");
     }
+    QStringList predefSchemesNamesLower;
+    for (int i = 0; i < predefSchemesNames.size(); ++i)
+    {
+        predefSchemesNamesLower.append(predefSchemesNames[i].toLower());
+    }
     if (!QDir(directory).exists()) {
         QDir().mkdir(directory);
 
@@ -751,7 +756,7 @@
             legacyFileConfig.setArrayIndex(i);
 
             QString schemeName = legacyFileConfig.value(spNames[0]).toString();
-            if (!schemeName.isNull() && !predefSchemesNames.contains(schemeName))
+            if (!schemeName.isNull() && !predefSchemesNamesLower.contains(schemeName.toLower()))
             {
                 QList<QVariant> scheme;
                 QFile file(directory + "/" + schemeName + ".hwg");
@@ -794,6 +799,11 @@
             if (schemeName.endsWith(".hwg", Qt::CaseInsensitive)) {
                 schemeName.chop(4);
             }
+            // Don't load scheme if name collides with default scheme
+            if (predefSchemesNamesLower.contains(schemeName.toLower())) {
+                qWarning("Game scheme \"%s\" not loaded from file, name collides with a default scheme!", qPrintable(schemeName));
+                continue;
+            }
             // Parse game scheme file
             if (file.open(QIODevice::ReadOnly)) {
                 QTextStream stream(&file);