Provide upgrade path to copy the MidiAlsaRaw 'Device' property to new 'device'

This commit is contained in:
Colin Wallace
2015-08-23 21:35:43 -07:00
parent 697aebc056
commit 0f2da6f68b
2 changed files with 49 additions and 6 deletions

View File

@@ -228,6 +228,7 @@ public:
const QString & _attribute ) const;
void setValue( const QString & _class, const QString & _attribute,
const QString & _value );
void deleteValue( const QString & cls, const QString & attribute);
void loadConfigFile();
void saveConfigFile();
@@ -256,7 +257,8 @@ private:
ConfigManager( const ConfigManager & _c );
~ConfigManager();
void upgrade_1_1_90();
void upgrade_1_2_0();
void upgrade();
const QString m_lmmsRcFile;

View File

@@ -104,7 +104,31 @@ ConfigManager::~ConfigManager()
}
void ConfigManager::upgrade_1_1_90()
{
// Remove trailing " (bad latency!)" string which was once saved with PulseAudio
if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) )
{
setValue("mixer", "audiodev", "PulseAudio");
}
}
void ConfigManager::upgrade_1_2_0()
{
// MidiAlsaRaw used to store the device info as "Device" instead of "device"
if ( value( "MidiAlsaRaw", "device" ).isNull() )
{
// copy "device" = "Device" and then delete the old "Device" (further down)
QString oldDevice = value( "MidiAlsaRaw", "Device" );
setValue("MidiAlsaRaw", "device", oldDevice);
}
if ( !value( "MidiAlsaRaw", "device" ).isNull() )
{
// delete the old "Device" in the case that we just copied it to "device"
// or if the user somehow set both the "Device" and "device" fields
deleteValue("MidiAlsaRaw", "Device");
}
}
void ConfigManager::upgrade()
{
@@ -116,13 +140,14 @@ void ConfigManager::upgrade()
ProjectVersion createdWith = m_version;
// Remove trailing " (bad latency!)" string which was once saved with PulseAudio
if ( createdWith.setCompareType(Build) < "1.1.90" )
{
if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) )
{
setValue("mixer", "audiodev", "PulseAudio");
}
upgrade_1_1_90();
}
if ( createdWith.setCompareType(Build) < "1.2.0" )
{
upgrade_1_2_0();
}
// Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc)
@@ -295,6 +320,22 @@ void ConfigManager::setValue( const QString & _class,
}
void ConfigManager::deleteValue( const QString & cls, const QString & attribute)
{
if( m_settings.contains( cls ) )
{
for( stringPairVector::iterator it = m_settings[cls].begin();
it != m_settings[cls].end(); ++it )
{
if( ( *it ).first == attribute )
{
m_settings[cls].erase(it);
return;
}
}
}
}
void ConfigManager::loadConfigFile()
{