VirtualBox

Changeset 51418 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
May 27, 2014 8:49:47 AM (11 years ago)
Author:
vboxsync
Message:

Main/Settings: try to catch forgotten updating of Settings.cpp when a new settings version is added, only for debug builds (otherwise behavior is very similar to previous one)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r51212 r51418  
    895895            break;
    896896
    897         case SettingsVersion_Future:
    898             // can be set if this code runs on XML files that were created by a future version of VBox;
    899             // in that case, downgrade to current version when writing since we can't write future versions...
    900             pcszVersion = "1.15";
    901             m->sv = SettingsVersion_v1_15;
    902             break;
    903 
    904897        default:
     898            // catch human error: the assertion below will trigger in debug
     899            // or dbgopt builds, so hopefully this will get noticed sooner in
     900            // the future, because it's easy to forget top update something.
     901            AssertMsg(m->sv <= SettingsVersion_v1_7, ("Settings.cpp: unexpected settings version %d, unhandled future version?\n", m->sv));
    905902            // silently upgrade if this is less than 1.7 because that's the oldest we can write
    906             pcszVersion = "1.7";
    907             m->sv = SettingsVersion_v1_7;
     903            if (m->sv <= SettingsVersion_v1_7)
     904            {
     905                pcszVersion = "1.7";
     906                m->sv = SettingsVersion_v1_7;
     907            }
     908            else
     909            {
     910                // This is reached for SettingsVersion_Future and forgotten
     911                // settings version after SettingsVersion_v1_7, which should
     912                // not happen (see assertion above). Set the version to the
     913                // latest known version, to minimize loss of information, but
     914                // as we can't predict the future we have to use some format
     915                // we know, and latest should be the best choice. Note that
     916                // for "forgotten settings" this may not be the best choice,
     917                // but as it's an omission of someone who changed this file
     918                // it's the only generic possibility.
     919                pcszVersion = "1.15";
     920                m->sv = SettingsVersion_v1_15;
     921            }
    908922            break;
    909923    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette