|
|
|
04-18-2018, 02:58 PM
|
#1
|
Banned
Join Date: Sep 2015
Posts: 1,650
|
Undo_ in ReaScript issue... SOLVED
It seems to be that 5.40 is the last version that Undo_ in ReaScript works properly on my 'pute. Can anyone else confirm or deny?
Issue: with -1 as the flag the Undo block is not recorded at all. With 0 set it is recorded but without a name ("ReaScript: run"). The correct name is still shown in the menu bar.
edit: MarkTrackItemsDirty is needed after using functions (defo MIDI_SetAllEvts) for Undo to work.
Last edited by snooks; 04-19-2018 at 07:49 AM.
|
|
|
04-18-2018, 03:07 PM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Works fine here.
Code:
-- (constants from reaper_plugin.h)
local UNDO_STATE_ALL = -1
local UNDO_STATE_TRACKCFG = 1 -- has track/master vol/pan/routing, ALL envelopes (matser included)
local UNDO_STATE_FX = 2 -- track/master fx
local UNDO_STATE_ITEMS = 4 -- track items
local UNDO_STATE_MISCCFG = 8 -- loop selection, markers, regions, extensions!
local UNDO_STATE_FREEZE = 16 -- freeze state -- note that isfreeze is used independently, this is only used for the undo system to serialize the already frozen state
reaper.Undo_BeginBlock()
-- do something here
reaper.Undo_EndBlock("Name of the undo point", UNDO_STATE_ALL)
|
|
|
04-18-2018, 03:16 PM
|
#3
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
I'm seeing the same issue here. An Undo block with -1 doesn't consistently generate anything in the undo history - some of my scripts work properly and some don't even manage a "Reascript: run" event.
|
|
|
04-18-2018, 03:49 PM
|
#4
|
Banned
Join Date: Sep 2015
Posts: 1,650
|
Interesting, it might be just in the Windows version then. Could Lokasenna or anyone else that sees this test 5.40 to see if it's fixed and 5.50 to see if it's broken?
|
|
|
04-18-2018, 10:36 PM
|
#5
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
Found old script that had UndoEndBlock2 with 0. Makes "ReaScript run" point. Pretty sure it used to enter the specified string.
Scripts using -1 work, but only if actually doing something undoable. Wanted to make named undo point with input box that didn't actually have a change in it, but it don't work that way.
I see there's a menu thingy in the undo history window where you can see some info about each state now.
Win 7 x64
|
|
|
04-18-2018, 11:00 PM
|
#6
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Could you upload an example of a script (or code snippet) that is not setting Undo properly?
I've also encountered some Undo issues, discussed in the thread ReaScript: Undo_EndBlock with flags != -1 are not added to undo history. The problem wasn't solved, but Justin answered:
Quote:
Originally Posted by Justin
If you don't call with flags=-1, it will look at undo flags set by the actions you're using in the middle of the block. Depending on what you're doing, you might not be marking things dirty correctly (which means the things edited won't be checked for changes, which would cause an undo point not to be added as you describe) -- what's happening in the middle of that block?
|
The bug might therefore be in the functions that are called inside the Undo block, rather than Undo itself. Although, Undo_OnStateChange_Item and Undo_OnStateChange2 appear to work more reliably.
Last edited by juliansader; 04-18-2018 at 11:19 PM.
|
|
|
04-19-2018, 02:33 AM
|
#7
|
Banned
Join Date: Sep 2015
Posts: 1,650
|
Good point, the scripts that aren't working use MIDI_SetAllEvts, here's a simple example where undo works in 5.40, but not 5.50+...
Code:
reaper.Undo_BeginBlock()
local ame = reaper.MIDIEditor_GetActive()
local take = reaper.MIDIEditor_GetTake(ame)
local evt1 = string.pack("i4Bs4", 2000, 0, string.char(0x90)..string.char(0x60)..string.char(0x7f))
local evt2 = string.pack("i4Bs4", 4000, 0, string.char(0x80)..string.char(0x60)..string.char(0x00))
reaper.MIDI_SetAllEvts(take, evt1 .. evt2)
reaper.Undo_EndBlock("Undo test", -1)
But it's okay, because MarkTrackItemsDirty makes it work (thanks for the link).
|
|
|
01-28-2020, 10:30 AM
|
#8
|
Human being with feelings
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
|
It's funny, but it also works for Reaper actions. For example, action 40179 resets the notes selection after the UNDO, but my script -
Code:
reaper.PreventUIRefresh(1);
reaper.MIDIEditor_LastFocused_OnCommand(40179,0)
reaper.PreventUIRefresh(-1);
reaper.Undo_OnStateChange2(0,'Pitch +12')
doesn’t
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 01:48 AM.
|