fix: guard persistBankOp/persistBook against a null session; rename promptText to promptBankName

This commit is contained in:
2026-07-29 13:06:12 -04:00
parent 430e117620
commit 4f587258b2
3 changed files with 34 additions and 17 deletions
+8 -8
View File
@@ -1,7 +1,7 @@
// bank_actions.cpp — the multi-bank bindable action family (Phase B3; Q-W4 split of
// actions.cpp). See bank_actions.h.
//
// Q-W4 dedupe: each mutating handler is a THIN UX SKIN — text prompts (promptText),
// Q-W4 dedupe: each mutating handler is a THIN UX SKIN — text prompts (promptBankName),
// name resolution, and console feedback — over the promptless bankOp* inner verbs
// homed in panel_bank_ops (model op + persistBankOp, one bank op = one Ctrl-Z). The
// book's rules (pool privileges, collapse-by-hash, active-fallback-to-pool) all live
@@ -28,7 +28,7 @@
#include "core/model/bank_book.h" // BankBook, nextBankId, kPoolBankId (B1)
#include "persist.h" // ReaSamplerSession (owns book())
#include "shell/panel/panel_bank_ops.h" // bankOp* inner verbs + promptText + selection seam
#include "shell/panel/panel_bank_ops.h" // bankOp* inner verbs + promptBankName + selection seam
#include "shell/panel/panel_layout.h" // full-height toggles (B3)
#define REAPERAPI_MINIMAL
@@ -115,7 +115,7 @@ std::string bankIdByDisplayName(const std::string& name) {
// create then fails and the user is told the name is taken.
void doBankCreate() {
std::string name;
if (!promptText("ReaSampler: create bank", "Bank name:", "", name)) return;
if (!promptBankName("ReaSampler: create bank", "Bank name:", "", name)) return;
if (bankOpCreate(name).empty()) {
ShowConsoleMsg(
("ReaSampler: could not create bank \"" + name +
@@ -129,7 +129,7 @@ void doBankCreate() {
// self-contained; the panel renames in place on a tab.
void doBankRename() {
std::string which;
if (!promptText("ReaSampler: rename bank", "Bank to rename (current name):", "",
if (!promptBankName("ReaSampler: rename bank", "Bank to rename (current name):", "",
which))
return;
const std::string id = bankIdByDisplayName(which);
@@ -138,7 +138,7 @@ void doBankRename() {
return;
}
std::string newName;
if (!promptText("ReaSampler: rename bank", "New name:", which, newName)) return;
if (!promptBankName("ReaSampler: rename bank", "New name:", which, newName)) return;
if (!bankOpRename(id, newName)) {
// The verb rejects the pool (un-renamable) or a name already used by another
// bank (unique display names, trimmed + case-insensitive).
@@ -154,7 +154,7 @@ void doBankRename() {
// panel confirm (naming evacuate inline, with a one-click evacuate) lives in the panel.
void doBankDelete() {
std::string which;
if (!promptText("ReaSampler: delete bank", "Bank to delete:", "", which)) return;
if (!promptBankName("ReaSampler: delete bank", "Bank to delete:", "", which)) return;
const std::string id = bankIdByDisplayName(which);
if (id.empty()) {
ShowConsoleMsg(("ReaSampler: no bank named \"" + which + "\".\n").c_str());
@@ -194,7 +194,7 @@ void doBankDelete() {
// intended "keep the samples" companion to delete.
void doBankEvacuate() {
std::string which;
if (!promptText("ReaSampler: evacuate bank", "Bank to evacuate to the pool:", "",
if (!promptBankName("ReaSampler: evacuate bank", "Bank to evacuate to the pool:", "",
which))
return;
const std::string id = bankIdByDisplayName(which);
@@ -245,7 +245,7 @@ void doBankTransferSelected(bool copy) {
const char* verb = copy ? "copy" : "move";
const std::string title = std::string("ReaSampler: ") + verb + " selected samples";
std::string destName;
if (!promptText(title.c_str(), "Destination bank:", "", destName)) return;
if (!promptBankName(title.c_str(), "Destination bank:", "", destName)) return;
const std::string destId = bankIdByDisplayName(destName);
if (destId.empty()) {
ShowConsoleMsg(("ReaSampler: no bank named \"" + destName + "\".\n").c_str());