fix(persist): call MarkProjectDirty after every SetProjExtState write

After capture, saveToActiveProject wrote ext state but left the project
clean, so Ctrl+S was a no-op and the bank was silently lost on close.
Also flushes the Save-As re-GUID on the normal save flow.
This commit is contained in:
2026-07-22 20:15:10 -04:00
parent 6a09e1d48d
commit f310913da5
+5 -1
View File
@@ -54,6 +54,7 @@
#define REAPERAPI_MINIMAL #define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_EnumProjects #define REAPERAPI_WANT_EnumProjects
#define REAPERAPI_WANT_GetProjExtState #define REAPERAPI_WANT_GetProjExtState
#define REAPERAPI_WANT_MarkProjectDirty
#define REAPERAPI_WANT_SetProjExtState #define REAPERAPI_WANT_SetProjExtState
#define REAPERAPI_WANT_ShowConsoleMsg #define REAPERAPI_WANT_ShowConsoleMsg
#define REAPERAPI_WANT_genGuid #define REAPERAPI_WANT_genGuid
@@ -162,6 +163,7 @@ void ReaSamplerSession::saveToActiveProject() {
const std::string json = bank_.serialize(); const std::string json = bank_.serialize();
SetProjExtState(static_cast<ReaProject*>(proj), kProjExtNamespace, SetProjExtState(static_cast<ReaProject*>(proj), kProjExtNamespace,
kProjExtIndexKey, json.c_str()); kProjExtIndexKey, json.c_str());
MarkProjectDirty(static_cast<ReaProject*>(proj));
} }
void ReaSamplerSession::loadFromProject(void* proj, const std::string& projectDir) { void ReaSamplerSession::loadFromProject(void* proj, const std::string& projectDir) {
@@ -266,11 +268,13 @@ void ReaSamplerSession::poll() {
// Save-As duplicated our ext state, so the new project B currently // Save-As duplicated our ext state, so the new project B currently
// shares A's GUID. Mint a FRESH GUID for B and write it, so A and B // shares A's GUID. Mint a FRESH GUID for B and write it, so A and B
// no longer collide on identity when reopened later. Adopt the fresh // no longer collide on identity when reopened later. Adopt the fresh
// GUID as our last-seen identity. // GUID as our last-seen identity. Mark dirty so the fresh GUID flushes
// to the new .rpp on the next normal save / close-prompt.
const std::string fresh = genProjectGuidString(); const std::string fresh = genProjectGuidString();
if (proj) { if (proj) {
SetProjExtState(static_cast<ReaProject*>(proj), kProjExtNamespace, SetProjExtState(static_cast<ReaProject*>(proj), kProjExtNamespace,
kProjExtGuidKey, fresh.c_str()); kProjExtGuidKey, fresh.c_str());
MarkProjectDirty(static_cast<ReaProject*>(proj));
} }
lastGuid_ = fresh; lastGuid_ = fresh;
lastRppPath_ = rppPath; lastRppPath_ = rppPath;