Load external curves with fallback to default, then message
| 38 | // Load external curves with fallback to default, then message |
| 39 | // |
| 40 | void EQCurveReader::LoadCurves(const wxString &fileName, bool append) |
| 41 | { |
| 42 | // We've disabled the XML management of curves. |
| 43 | // Just going via .cfg files now. |
| 44 | #ifndef LEGACY_EQ |
| 45 | (void)fileName; |
| 46 | (void)append; |
| 47 | mCurves.clear(); |
| 48 | mCurves.push_back( wxT("unnamed") ); // we still need a default curve to use |
| 49 | #else |
| 50 | // Construct normal curve filename |
| 51 | // |
| 52 | // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict |
| 53 | // between wxStandardPaths and wxConfig under Linux. The latter |
| 54 | // creates a normal file as "$HOME/.audacity", while the former |
| 55 | // expects the ".audacity" portion to be a directory. |
| 56 | // MJS: I don't know what the above means, or if I have broken it. |
| 57 | wxFileName fn; |
| 58 | |
| 59 | if(fileName.empty()) { |
| 60 | // Check if presets are up to date. |
| 61 | wxString eqCurvesCurrentVersion = wxString::Format(wxT("%d.%d"), EQCURVES_VERSION, EQCURVES_REVISION); |
| 62 | wxString eqCurvesInstalledVersion; |
| 63 | gPrefs->Read(GetPrefsPrefix() + "PresetVersion", &eqCurvesInstalledVersion, wxT("")); |
| 64 | |
| 65 | bool needUpdate = (eqCurvesCurrentVersion != eqCurvesInstalledVersion); |
| 66 | |
| 67 | // UpdateDefaultCurves allows us to import NEW factory presets only, |
| 68 | // or update all factory preset curves. |
| 69 | if (needUpdate) |
| 70 | UpdateDefaultCurves( UPDATE_ALL != 0 ); |
| 71 | fn = wxFileName( FileNames::DataDir(), wxT("EQCurves.xml") ); |
| 72 | } |
| 73 | else |
| 74 | fn = fileName; // user is loading a specific set of curves |
| 75 | |
| 76 | // If requested file doesn't exist... |
| 77 | if( !fn.FileExists() && !GetDefaultFileName(fn) ) { |
| 78 | mCurves.clear(); |
| 79 | /* i18n-hint: name of the 'unnamed' custom curve */ |
| 80 | mCurves.push_back( _("unnamed") ); // we still need a default curve to use |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | EQCurve tempCustom(wxT("temp")); |
| 85 | if( append == false ) // Start from scratch |
| 86 | mCurves.clear(); |
| 87 | else // appending so copy and remove 'unnamed', to replace later |
| 88 | { |
| 89 | tempCustom.points = mCurves.back().points; |
| 90 | mCurves.pop_back(); |
| 91 | } |
| 92 | |
| 93 | // Load the curves |
| 94 | XMLFileReader reader; |
| 95 | const wxString fullPath{ fn.GetFullPath() }; |
| 96 | if( !reader.Parse( this, fullPath ) ) |
| 97 | { |
no test coverage detected