# HG changeset patch # User unc0rr # Date 1361046353 -14400 # Node ID f849b7b3af1d389b7ccdfaa4207ef54b11dfbb27 # Parent f4475782cf4558b0de317f84c802a24c404ca2fe - 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 diff -r f4475782cf45 -r f849b7b3af1d QTfrontend/main.cpp --- 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; { diff -r f4475782cf45 -r f849b7b3af1d QTfrontend/team.cpp --- 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); diff -r f4475782cf45 -r f849b7b3af1d QTfrontend/util/DataManager.cpp --- 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; +} diff -r f4475782cf45 -r f849b7b3af1d QTfrontend/util/DataManager.h --- 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(); diff -r f4475782cf45 -r f849b7b3af1d project_files/hedgewars.pro --- 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 \