From 92254e8c98bb4d573c2a13debb80decad6f1e7d0 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sun, 15 Dec 2019 23:53:11 +0100 Subject: [PATCH] Corrected a bug with `default_path` The default path was not properly reset when loading a new file --- src/sfizz/Synth.cpp | 1 + tests/FilesT.cpp | 10 ++++++++++ tests/TestFiles/default_path_reset.sfz | 1 + 3 files changed, 12 insertions(+) create mode 100644 tests/TestFiles/default_path_reset.sfz diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 5c01eda0..fba33cc8 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -136,6 +136,7 @@ void sfz::Synth::clear() numCurves = 0; fileTicket = -1; defaultSwitch = absl::nullopt; + defaultPath = ""; midiState.reset(); ccNames.clear(); globalOpcodes.clear(); diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 563fa38f..bbc8bf23 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -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)"); } \ No newline at end of file diff --git a/tests/TestFiles/default_path_reset.sfz b/tests/TestFiles/default_path_reset.sfz new file mode 100644 index 00000000..55a4bea6 --- /dev/null +++ b/tests/TestFiles/default_path_reset.sfz @@ -0,0 +1 @@ + sample=DefaultPath/SubPath2/sample2.wav \ No newline at end of file