Fall back to focused tab when getReaperParent(3) is null

REAPER may not expose the parent project pointer during plugin creation/setState, so the instrument would silently resolve no sample roots. Only that null-parent case now falls back to EnumProjects(-1); a resolved-but-unlisted or unsaved project still resolves nothing.
This commit is contained in:
2026-09-25 14:59:07 -04:00
parent 0976ea13a8
commit cb6b63cc88
6 changed files with 62 additions and 24 deletions
+15
View File
@@ -64,6 +64,18 @@ static void testNoOpenProjectsResolvesNothing() {
CHECK(ownProjectDir(&projA, {}).empty());
}
static void testNullOwnFallsBackToTheActiveTab() {
CHECK(ownProjectDir(nullptr, threeTabs(), &projB) == "c:/projects/b");
}
static void testNullOwnAndNullFallbackResolvesNothing() {
CHECK(ownProjectDir(nullptr, threeTabs(), nullptr).empty());
}
static void testNonNullOwnIgnoresTheFallback() {
CHECK(ownProjectDir(&stranger, threeTabs(), &projB).empty());
}
// --- sampleRootCandidates -----------------------------------------------------
static void testProjectDirIsTheOnlyCandidate() {
@@ -141,6 +153,9 @@ int main() {
testUnlistedProjectResolvesNothingRatherThanAnotherTab();
testUnsavedOwnProjectResolvesNothingEvenBesideSavedTabs();
testNoOpenProjectsResolvesNothing();
testNullOwnFallsBackToTheActiveTab();
testNullOwnAndNullFallbackResolvesNothing();
testNonNullOwnIgnoresTheFallback();
testProjectDirIsTheOnlyCandidate();
testNoProjectDirMeansNoCandidates();