- Ensure that team file exists before saving into it (same fix as for hedgewars.ini, due to bug in Qt)
authorunc0rr
Sun, 17 Feb 2013 00:25:53 +0400
changeset 8508 f849b7b3af1d
parent 8507 f4475782cf45
child 8509 eda9f2106d8d
- Ensure that team file exists before saving into it (same fix as for hedgewars.ini, due to bug in Qt) - Fix build with .pro file
QTfrontend/main.cpp
QTfrontend/team.cpp
QTfrontend/util/DataManager.cpp
QTfrontend/util/DataManager.h
project_files/hedgewars.pro
--- a/QTfrontend/main.cpp	Sat Feb 16 23:28:16 2013 +0400
+++ b/QTfrontend/main.cpp	Sun Feb 17 00:25:53 2013 +0400
@@ -120,15 +120,6 @@
     return true;
 }
 
-bool checkForFile(const QString & file)
-{
-    QFile tmpfile(file);
-    if (!tmpfile.exists())
-        return tmpfile.open(QFile::WriteOnly);
-    else
-        return true;
-}
-
 // Guaranteed to be the last thing ran in the application's life time.
 // Closes resources that need to exist as long as possible.
 void closeResources(void)
@@ -296,7 +287,7 @@
     engine->setWriteDir(cfgdir->absolutePath());
     engine->mountPacks();
 
-    checkForFile("physfs://hedgewars.ini");
+    DataManager::ensureFileExists("physfs://hedgewars.ini");
 
     QTranslator Translator;
     {
--- a/QTfrontend/team.cpp	Sat Feb 16 23:28:16 2013 +0400
+++ b/QTfrontend/team.cpp	Sun Feb 17 00:25:53 2013 +0400
@@ -226,7 +226,9 @@
         OldTeamName = m_name;
     }
 
-    QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0);
+    QString fileName = QString("physfs://Teams/%1.hwt").arg(m_name);
+    DataManager::ensureFileExists(fileName);
+    QSettings teamfile(fileName, QSettings::IniFormat, 0);
     teamfile.setIniCodec("UTF-8");
     teamfile.setValue("Team/Name", m_name);
     teamfile.setValue("Team/Grave", m_grave);
--- a/QTfrontend/util/DataManager.cpp	Sat Feb 16 23:28:16 2013 +0400
+++ b/QTfrontend/util/DataManager.cpp	Sun Feb 17 00:25:53 2013 +0400
@@ -176,3 +176,12 @@
         m_colorsModel->item(i)->setData(QColor(colors[i]));
     }
 }
+
+bool DataManager::ensureFileExists(const QString &fileName)
+{
+    QFile tmpfile(fileName);
+    if (!tmpfile.exists())
+        return tmpfile.open(QFile::WriteOnly);
+    else
+        return true;
+}
--- a/QTfrontend/util/DataManager.h	Sat Feb 16 23:28:16 2013 +0400
+++ b/QTfrontend/util/DataManager.h	Sun Feb 17 00:25:53 2013 +0400
@@ -117,6 +117,8 @@
         QStandardItemModel * colorsModel();
         QStandardItemModel * bindsModel();
 
+        static bool ensureFileExists(const QString & fileName);
+
     public slots:
         /// Reloads data from storage.
         void reload();
--- a/project_files/hedgewars.pro	Sat Feb 16 23:28:16 2013 +0400
+++ b/project_files/hedgewars.pro	Sun Feb 17 00:25:53 2013 +0400
@@ -114,9 +114,9 @@
     ../QTfrontend/util/MessageDialog.h \
     ../QTfrontend/ui/widget/hatprompt.h \
     ../QTfrontend/ui/widget/feedbackdialog.h \
-    ../QTfrontend/ui/widget/flowlayout.h \
     ../QTfrontend/ui/widget/lineeditcursor.h \
-    ../QTfrontend/servermessages.h
+    ../QTfrontend/servermessages.h \
+    ../QTfrontend/ui/widget/roomnameprompt.h
 
 
 SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
@@ -214,8 +214,8 @@
     ../QTfrontend/ui/widget/themeprompt.cpp \
     ../QTfrontend/util/MessageDialog.cpp \
     ../QTfrontend/ui/widget/feedbackdialog.cpp \
-    ../QTfrontend/ui/widget/flowlayout.cpp \
-    ../QTfrontend/ui/widget/lineeditcursor.cpp
+    ../QTfrontend/ui/widget/lineeditcursor.cpp \
+    ../QTfrontend/ui/widget/roomnameprompt.cpp
 
 
 TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \