One undo-block opener for the whole tree: fourteen sites route through it, and the reclaim span can no longer swallow a user's act
The drain refuses a tick inside a foreign block; applyMode wakes the reclaimer before it opens the span.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// See undo_block.h. Compiled into the reaper_reasampler module; includes
|
||||
// reaper_plugin_functions.h without REAPERAPI_IMPLEMENT (main.cpp owns that).
|
||||
|
||||
#include "shell/undo/undo_block.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "shell/view/fx_reclaim.h" // fxReclaimEndUndoSpan — the span this must not nest over
|
||||
|
||||
#define REAPERAPI_MINIMAL
|
||||
#define REAPERAPI_WANT_Undo_BeginBlock2
|
||||
#define REAPERAPI_WANT_Undo_EndBlock2
|
||||
#include "reaper_plugin_functions.h"
|
||||
|
||||
namespace reasampler {
|
||||
|
||||
namespace {
|
||||
|
||||
// Extension-owned nesting depth only — REAPER's own counter is not readable, and the
|
||||
// reclaim span is deliberately NOT counted here (it is the thing this stands off).
|
||||
int g_depth = 0;
|
||||
|
||||
} // namespace
|
||||
|
||||
bool undoBlockOpen() { return g_depth > 0; }
|
||||
|
||||
UndoBlock::UndoBlock(ReaProject* proj) : project_(proj) {
|
||||
// ONLY the outermost block ends the span, which mechanizes the whole nesting rule.
|
||||
// At depth 0 the span is the only block that can be open, so ending it mints the
|
||||
// switch's point whole, at depth 0, before this block exists. At depth > 0 the
|
||||
// enclosing UndoBlock already did it, and a close from here would land at depth
|
||||
// 2->1 — minting nothing and hijacking the enclosing block's label instead. That is
|
||||
// the same criterion applyMode's reapply is gated on.
|
||||
if (g_depth++ == 0) fxReclaimEndUndoSpan();
|
||||
Undo_BeginBlock2(proj);
|
||||
}
|
||||
|
||||
UndoBlock::~UndoBlock() {
|
||||
// Depth drops AFTER the SDK call, not before: the close that reaches depth 0 mints a
|
||||
// point, and anything re-entered through that must still read a block as open rather
|
||||
// than let the drain open a span underneath it.
|
||||
Undo_EndBlock2(project_, label_.c_str(), mask_);
|
||||
--g_depth;
|
||||
}
|
||||
|
||||
void UndoBlock::recordPoint(std::string label, int mask) {
|
||||
label_ = std::move(label);
|
||||
mask_ = mask;
|
||||
}
|
||||
|
||||
} // namespace reasampler
|
||||
Reference in New Issue
Block a user