From: <hep...@us...> - 2013-12-26 04:37:46
|
Revision: 1340 http://sourceforge.net/p/qterm/code/1340 Author: hephooey Date: 2013-12-26 04:37:41 +0000 (Thu, 26 Dec 2013) Log Message: ----------- Backup the old config file Modified Paths: -------------- trunk/qterm/src/qtermconfig.cpp trunk/qterm/src/qtermconfig.h Modified: trunk/qterm/src/qtermconfig.cpp =================================================================== --- trunk/qterm/src/qtermconfig.cpp 2013-12-26 03:24:50 UTC (rev 1339) +++ trunk/qterm/src/qtermconfig.cpp 2013-12-26 04:37:41 UTC (rev 1340) @@ -31,7 +31,7 @@ { if (QFile::exists(szFileName)) { m_settings = new QSettings(szFileName, QSettings::IniFormat); - checkVersion(); + checkVersion(szFileName); } else { m_settings = new QSettings(szFileName, QSettings::IniFormat); m_settings->setValue("version", m_version); @@ -98,7 +98,7 @@ m_settings->endGroup(); } -bool Config::checkVersion() +bool Config::checkVersion(const QString & szFileName) { QString version = m_settings->value("version").toString(); @@ -106,7 +106,16 @@ QMessageBox::warning(0, "Old Version","The version of your config file is outdated.\n" "It will be automatically updated, but you should check for errors"); upgrade(); } else if (m_version != version) { - QMessageBox::warning(0, "Version Mismath","The version of your config file is not match the current QTerm version.\n" "It will be automatically updated, but you should check for errors"); + QString bakFile = szFileName+".bak"; + QMessageBox::warning(0, "Version Mismath","The version of your config file is not match the current QTerm version.\n" "The old config file will be backed up as: "+bakFile); + + if (QFile::exists(bakFile)) + { + QFile::remove(bakFile); + } + + QFile::copy(szFileName, bakFile); + m_settings->setValue("version", m_version); upgrade(); return false; Modified: trunk/qterm/src/qtermconfig.h =================================================================== --- trunk/qterm/src/qtermconfig.h 2013-12-26 03:24:50 UTC (rev 1339) +++ trunk/qterm/src/qtermconfig.h 2013-12-26 04:37:41 UTC (rev 1340) @@ -29,7 +29,7 @@ private: bool checkError(); - bool checkVersion(); + bool checkVersion(const QString & szFileName); void upgrade(); void addShortcuts(); void addToolBars(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |