MCPcopy Create free account
hub / github.com/audacity/audacity / Commit

Method Commit

src/prefs/KeyConfigPrefs.cpp:887–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887bool KeyConfigPrefs::Commit()
888{
889 // On the Mac, preferences may be changed without any active
890 // projects. This means that the CommandManager isn't available
891 // either. So we can't attempt to save preferences, otherwise
892 // NULL ptr dereferences will happen in ShuttleGui because the
893 // radio buttons are never created. (See Populate() above.)
894 if ( !mProject ) {
895 return true;
896 }
897
898 ShuttleGui S(this, eIsSavingToPrefs);
899 PopulateOrExchange(S);
900
901 bool bFull = gPrefs->ReadBool(wxT("/GUI/Shortcuts/FullDefaults"), false);
902 for (size_t i = 0; i < mNames.size(); i++) {
903 const auto &dkey = bFull ? mDefaultKeys[i] : mStandardDefaultKeys[i];
904 // using GET to interpret CommandID as a config path component
905 auto name = wxT("/NewKeys/") + mNames[i].GET();
906 const auto &key = mNewKeys[i];
907
908 if (gPrefs->HasEntry(name)) {
909 if (key != NormalizedKeyString{ gPrefs->ReadObject(name, key) } ) {
910 gPrefs->Write(name, key);
911 }
912 if (key == dkey) {
913 gPrefs->DeleteEntry(name);
914 }
915 }
916 else {
917 if (key != dkey) {
918 gPrefs->Write(name, key);
919 }
920 }
921 }
922
923 return gPrefs->Flush();
924}
925
926void KeyConfigPrefs::Cancel()
927{

Callers 1

OnExportMethod · 0.45

Calls 7

ReadBoolMethod · 0.80
PopulateOrExchangeFunction · 0.50
sizeMethod · 0.45
HasEntryMethod · 0.45
WriteMethod · 0.45
DeleteEntryMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected