fix(instrument_drop_win): make performInstrumentDrop all-or-nothing
On chunk-write failure, call TrackFX_Delete(track, fxIndex) to remove the just-added empty FX instance before returning false. Signature verified at reaper_plugin_functions.h:7236. Update the header comment from "leaves at most the added FX" to the new all-or-nothing contract.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#define REAPERAPI_MINIMAL
|
||||
#define REAPERAPI_WANT_GetThingFromPoint
|
||||
#define REAPERAPI_WANT_TrackFX_AddByName
|
||||
#define REAPERAPI_WANT_TrackFX_Delete
|
||||
#define REAPERAPI_WANT_TrackFX_SetNamedConfigParm
|
||||
#define REAPERAPI_WANT_Undo_BeginBlock2
|
||||
#define REAPERAPI_WANT_Undo_EndBlock2
|
||||
@@ -73,6 +74,12 @@ bool performInstrumentDrop(MediaTrack* track, const std::string& chunkBase64) {
|
||||
// (instrument_drop::buildInstrumentDropChunk -> sample_map::serializeComponentState),
|
||||
// so these bytes are exactly what ReaSampler 9000's setState accepts.
|
||||
ok = TrackFX_SetNamedConfigParm(track, fxIndex, "vst_chunk", chunkBase64.c_str());
|
||||
if (!ok) {
|
||||
// All-or-nothing: if the chunk write fails, remove the empty FX instance we just
|
||||
// added so the track is left exactly as it was. TrackFX_Delete signature (verified
|
||||
// in reaper_plugin_functions.h:7236): bool TrackFX_Delete(MediaTrack*, int fx).
|
||||
TrackFX_Delete(track, fxIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// The undo label reflects the placement-of-the-player framing (not a capture, not an insert).
|
||||
|
||||
Reference in New Issue
Block a user