QTfrontend/ui/widget/selectWeapon.cpp
changeset 13196 f93658732448
parent 13195 7d9462d49d4c
child 13314 fe85ba81b01b
--- a/QTfrontend/ui/widget/selectWeapon.cpp	Wed Mar 14 12:17:11 2018 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.cpp	Wed Mar 14 14:42:50 2018 +0100
@@ -111,6 +111,7 @@
                 if (file.open(QIODevice::WriteOnly)) {
                     QTextStream stream( &file );
                     stream << old_wconf.value(keys[i]).toString() << endl;
+                    file.close();
                 }
                 imported++;
             }
@@ -131,13 +132,18 @@
 
             QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + schemes[i]);
             QString config;
-
             if (file.open(QIODevice::ReadOnly)) {
                 QTextStream stream( &file );
                 stream >> config;
+                file.close();
             }
 
-            wconf->setValue(schemes[i].remove(".hwa"), fixWeaponSet(config));
+            // Chop off file name suffix
+            QString schemeName = schemes[i];
+            if (schemeName.endsWith(".hwa", Qt::CaseInsensitive)) {
+                schemeName.chop(4);
+            }
+            wconf->setValue(schemeName, fixWeaponSet(config));
         }
     }
 
@@ -300,6 +306,7 @@
     if (file.open(QIODevice::WriteOnly)) {
         QTextStream stream( &file );
         stream << stateFull << endl;
+        file.close();
     }
     emit weaponsEdited(curWeaponsName, m_name->text(), stateFull);
 }