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
+5 -3
View File
@@ -6,10 +6,12 @@
namespace reasampler::instrument::map {
std::string ownProjectDir(const void* own, const std::vector<ProjectTab>& open) {
if (!own) return {};
std::string ownProjectDir(const void* own, const std::vector<ProjectTab>& open,
const void* activeFallback) {
const void* target = own ? own : activeFallback;
if (!target) return {};
for (const ProjectTab& tab : open) {
if (tab.project == own) return capture::projectDirOfRpp(tab.rppPath);
if (tab.project == target) return capture::projectDirOfRpp(tab.rppPath);
}
return {};
}
+11 -5
View File
@@ -19,11 +19,17 @@ struct ProjectTab {
std::string rppPath;
};
// The directory of the project whose identity is `own`; empty when `own` is null, is not
// among `open`, or was never saved. Deliberately no fallback to any other project: another
// project's bank folder can hold a same-named file, and playing it is the wrong-project
// bug this exists to close.
std::string ownProjectDir(const void* own, const std::vector<ProjectTab>& open);
// The directory of the project whose identity is `own`; empty when `own` is not among
// `open` or was never saved. Deliberately no fallback to any other project for a
// NON-NULL `own`: another project's bank folder can hold a same-named file, and playing
// it is the wrong-project bug this exists to close.
//
// `activeFallback` is used ONLY when `own` is null (REAPER may not expose
// getReaperParent(3) yet during plugin creation/setState) — then it stands in for `own`
// unchanged, so a still-null fallback (or one absent from `open`) resolves nothing exactly
// as a null `own` always did.
std::string ownProjectDir(const void* own, const std::vector<ProjectTab>& open,
const void* activeFallback = nullptr);
// The roots a bank-relative path is tried against, in order. Only the project directory
// today — the ordered list is the seam a later root (tried after it) extends. Empty when