Added check for valid settings file to OSX code, which doesn't save its

settings in an ini file, but uses its own plist.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1217 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-12-15 17:52:03 +00:00
parent e5275949d4
commit 7b84459e83
3 changed files with 21 additions and 13 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.cxx,v 1.101 2006-12-15 16:42:58 stephena Exp $
// $Id: Settings.cxx,v 1.102 2006-12-15 17:52:03 stephena Exp $
//============================================================================
#include <cassert>
@ -25,14 +25,6 @@
#include "bspf.hxx"
#include "Settings.hxx"
// Specifies the minimum version of the settings file that's valid
// for this version of Stella. If the settings file is too old,
// the internal defaults are used.
// For each new release, this should only be bumped if there have been
// major changes in some settings; changes which could stop Stella from
// actually working.
#define MIN_SETTINGS_VERSION "2.3_alpha"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Settings::Settings(OSystem* osystem)
: myOSystem(osystem)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.hxx,v 1.28 2006-12-08 16:49:28 stephena Exp $
// $Id: Settings.hxx,v 1.29 2006-12-15 17:52:03 stephena Exp $
//============================================================================
#ifndef SETTINGS_HXX
@ -24,12 +24,19 @@ class OSystem;
#include "Array.hxx"
#include "bspf.hxx"
// Specifies the minimum version of the settings file that's valid
// for this version of Stella. If the settings file is too old,
// the internal defaults are used.
// For each new release, this should only be bumped if there have been
// major changes in some settings; changes which could stop Stella from
// actually working.
#define MIN_SETTINGS_VERSION "2.3_alpha"
/**
This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony
@version $Id: Settings.hxx,v 1.28 2006-12-08 16:49:28 stephena Exp $
@version $Id: Settings.hxx,v 1.29 2006-12-15 17:52:03 stephena Exp $
*/
class Settings
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: SettingsMACOSX.cxx,v 1.13 2006-12-08 16:49:37 stephena Exp $
// $Id: SettingsMACOSX.cxx,v 1.14 2006-12-15 17:52:03 stephena Exp $
//============================================================================
#include <cassert>
@ -27,6 +27,7 @@
#include "bspf.hxx"
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Version.hxx"
#include "Settings.hxx"
#include "SettingsMACOSX.hxx"
@ -56,7 +57,12 @@ void SettingsMACOSX::loadConfig()
string key, value;
char cvalue[2048];
// Write out each of the key and value pairs
// Check if the settings plist file is valid
prefsGetString("plist_version", cvalue);
if(cvalue[0] == 0 || string(cvalue) < string(MIN_SETTINGS_VERSION))
return;
// Read key/value pairs from the plist file
const SettingsArray& settings = getInternalSettings();
for(unsigned int i = 0; i < settings.size(); ++i)
{
@ -69,6 +75,9 @@ void SettingsMACOSX::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SettingsMACOSX::saveConfig()
{
// Write out plist version
prefsSetString("plist_version", STELLA_VERSION);
// Write out each of the key and value pairs
const SettingsArray& settings = getInternalSettings();
for(unsigned int i = 0; i < settings.size(); ++i)