Corrected a bug with default_path

The default path was not properly reset when loading a new file
This commit is contained in:
Paul Ferrand 2019-12-15 23:53:11 +01:00
parent 194816ef58
commit 92254e8c98
3 changed files with 12 additions and 0 deletions

View file

@ -136,6 +136,7 @@ void sfz::Synth::clear()
numCurves = 0;
fileTicket = -1;
defaultSwitch = absl::nullopt;
defaultPath = "";
midiState.reset();
ccNames.clear();
globalOpcodes.clear();

View file

@ -370,4 +370,14 @@ TEST_CASE("[Files] Default path")
REQUIRE(synth.getRegionView(1)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
REQUIRE(synth.getRegionView(2)->sample == R"(DefaultPath/SubPath1/sample1.wav)");
REQUIRE(synth.getRegionView(3)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
}
TEST_CASE("[Files] Default path reset when calling loadSfzFile again")
{
sfz::Synth synth;
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path.sfz");
REQUIRE(synth.getNumRegions() == 4);
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/default_path_reset.sfz");
REQUIRE(synth.getNumRegions() == 1);
REQUIRE(synth.getRegionView(0)->sample == R"(DefaultPath/SubPath2/sample2.wav)");
}

View file

@ -0,0 +1 @@
<region> sample=DefaultPath/SubPath2/sample2.wav