Route every extension bank-directory lookup through one bankRootOf seam
The pure bankRootFor(rppPath, unsavedRoot) and the shell bankRootOf(ReaProject*) replace eleven hand-rolled .rpp-parent derivations. No unsaved root is supplied yet, so behaviour and refusals are unchanged. Save-As relocation now reads the stored lastBankRoot_.
This commit is contained in:
@@ -32,12 +32,12 @@
|
||||
#include "core/model/bank_model.h"
|
||||
#include "shell/panel/panel_bank_ops.h" // bankPanelSelectedSampleIds / SourceBankId
|
||||
#include "core/capture/capture_paths.h"
|
||||
#include "shell/persist/bank_root.h"
|
||||
#include "shell/persist/session.h"
|
||||
#include "shell/undo/undo_block.h"
|
||||
|
||||
#define REAPERAPI_MINIMAL
|
||||
#define REAPERAPI_WANT_CountSelectedTracks
|
||||
#define REAPERAPI_WANT_EnumProjects
|
||||
#define REAPERAPI_WANT_GetCursorPosition
|
||||
#define REAPERAPI_WANT_GetSelectedTrack
|
||||
#define REAPERAPI_WANT_InsertMedia
|
||||
@@ -50,7 +50,6 @@
|
||||
namespace reasampler {
|
||||
|
||||
using capture::computeInsertMode;
|
||||
using capture::normalizeSlashes;
|
||||
using capture::resolveBankFile;
|
||||
using capture::TempoConform;
|
||||
|
||||
@@ -58,18 +57,6 @@ namespace {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
// Mirrors bank_panel/capture/persist's own derivation; the bank index stores
|
||||
// relative paths, so resolving a file needs the current .rpp dir. A shared "current
|
||||
// project dir" helper would be a clean small refactor now that a fourth consumer
|
||||
// exists (also noted in panel_bank_ops.cpp) — out of scope here.
|
||||
std::string currentProjectDir() {
|
||||
std::vector<char> buf(4096, '\0');
|
||||
EnumProjects(-1, buf.data(), static_cast<int>(buf.size()));
|
||||
std::string rpp(buf.data());
|
||||
if (rpp.empty()) return {}; // unsaved project: no resolvable bank
|
||||
return normalizeSlashes(fs::path(rpp).parent_path().string());
|
||||
}
|
||||
|
||||
// Snapshot of the currently-selected track set (master is skipped, matching
|
||||
// CountSelectedTracks/GetSelectedTrack), in selection order, for restore later.
|
||||
std::vector<MediaTrack*> snapshotSelectedTracks() {
|
||||
@@ -111,9 +98,9 @@ InsertResult runInsert(ReaSamplerSession* session, const InsertRequest& request)
|
||||
if (ids.empty()) { result.status = InsertStatus::NoSelection; return result; }
|
||||
const std::string& id = ids.front(); // focused / first selected — single sample
|
||||
|
||||
// WHERE: an unsaved project has no resolvable bank dir; no-op rather than
|
||||
// WHERE: no bank root means no resolvable bank file; no-op rather than
|
||||
// resolving against CWD.
|
||||
const std::string projectDir = currentProjectDir();
|
||||
const std::string projectDir = bankRootOf(nullptr);
|
||||
if (projectDir.empty()) { result.status = InsertStatus::NoProject; return result; }
|
||||
|
||||
// Resolve against the bank the selection came from — it may be the pool or a
|
||||
|
||||
Reference in New Issue
Block a user