Skip to content

Commit

Permalink
Store nifskope version in settings, and remove binary settings when v…
Browse files Browse the repository at this point in the history
…ersion does not match version stored in settings, to prevent problems when upgrading nifskope.
  • Loading branch information
amorilia committed Nov 17, 2012
1 parent 68cf51d commit 8757181
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
24 changes: 24 additions & 0 deletions nifskope.cpp
Expand Up @@ -101,6 +101,27 @@ FSManager * fsmanager = 0;

//! \file nifskope.cpp The main file for NifSkope

void NifSkope::migrateSettings() const
{
// load current nifskope settings
NIFSKOPE_QSETTINGS(cfg);
// check if we are running a new version of nifskope
if(cfg.value("version").toString() != NIFSKOPE_VERSION) {
// check all keys and delete all binary ones
//to prevent portability problems between Qt versions
QStringList keys = cfg.allKeys();
for (QStringList::ConstIterator key = keys.begin(); key != keys.end(); ++key) {
if (cfg.value(*key).type() == QVariant::ByteArray) {
qDebug() << "removing config setting" << *key
<< "whilst migrating settings from previous nifskope version";
cfg.remove(*key);
}
}
// set version key to current version
cfg.setValue("version", NIFSKOPE_VERSION);
}
}

/*
* main GUI window
*/
Expand All @@ -116,6 +137,9 @@ NifSkope::NifSkope()
// init UI parts
aboutDialog = new AboutDialog(this);

// migrate settings from older versions of NifSkope
migrateSettings();

// create a new nif
nif = new NifModel( this );
connect( nif, SIGNAL( sigMessage( const Message & ) ), this, SLOT( dispatchMessage( const Message & ) ) );
Expand Down
6 changes: 0 additions & 6 deletions nifskope.h
Expand Up @@ -188,12 +188,6 @@ protected slots:

void setViewFont( const QFont & );

//! Copy settings from one config to another, without overwriting keys.
/*!
* This is a helper function for migrateSettings().
*/
void copySettings(QSettings & cfg, const QSettings & oldcfg, const QString name) const;

//! Migrate settings from older versions of nifskope.
void migrateSettings() const;

Expand Down

0 comments on commit 8757181

Please sign in to comment.