02-14-2023, 11:15 AM
|
#1 |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
ReaScript: Run should appear in the Undo History ONLY when a script changes the REAPER memory state.
Unfortunately, there are many examples highlighted in this forum where these highly annoying and spurious Reascript: Run messages corrupt the Undo History. Please fix. Here's one more (totally vanilla REAPER 6.75, running on either Mac and Windows):
And voilà, you now have a corrupted Undo History with ReaScript: Run! ![]() This script simply counts the number of items on the newly created track and DOES NOTHING to change the memory state of REAPER. There is no meaning to "undoing" something that didn't DO anything! And furthermore, if reaper.CountTrackMediaItems or reaper.GetTrack ARE doing something to the REAPER memory state as undocumented side effects, then those are also bugs that need to be fixed. |
|
|
02-14-2023, 11:19 AM
|
#2 |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
This is how to have a script without undo:
Code:
function Main() reaper.CountTrackMediaItems(reaper.GetTrack(0,0)) end reaper.defer(Main)
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation |
|
|
02-14-2023, 11:21 AM
|
#3 | |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Quote:
It is corruption, because it does not reflect reality. It is fundamentally incorrect. |
|
|
|
02-14-2023, 12:36 PM
|
#4 |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
After further experimentation, I have confirmed that in this case the ReaScript: Run undo history corruption is caused by spurious side effects of reaper.CountTrackMediaItems.
This bug, and any others like it, need to be fixed. The work-around for now is to add the following line to your code to undo whatever spurious nonsense the reaper API function has created. Code:
reaper.Undo_OnStateChange("ReaScript: Run")
|
|
|
02-14-2023, 12:44 PM
|
#5 | |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
@JustSaying
Quote:
---- The defer script works. Code:
-- Your actual code reaper.CountTrackMediaItems(reaper.GetTrack(0,0)) -- End of your code reaper.defer(function() end) -- This question has already been answer by Justin himself: https://forum.cockos.com/showpost.ph...02&postcount=4 Just like my answer, it may not be satisfying I suppose. But it is what we got. We're on the same boat so don't blame me if there is no better way.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation |
|
|
|
02-14-2023, 01:01 PM
|
#6 | |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Quote:
Really hope we'll get an option to answer this dialog on the script side... Here's the FR
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
|
02-14-2023, 01:04 PM
|
#7 |
|
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,966
|
I once described how to recreate this behavior.
I noticed that the undo-points have stuff like sws cycle-actions in them, so the project is changed, but by something completely unrelated. Can you post the undo state? You can get it by opening the undo-list, right clicking the undo state and hit Show undo state information or something similar. Then a window appears with lines that have + at their beginnings. Copy n paste this, so I can add this to my old bugreport as another hint at the behavior. Edit: the example in the opening post should be the SWS-cycle actions added to the undo point from what it looks like.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people |
|
|
02-14-2023, 01:05 PM
|
#8 |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
I'm definitely +1 this FR. It is pretty rare that a script need two instances. I can only see heda's notes reader for that, and even this comes in several action in the action list to allow that ^^
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation |
|
|
02-14-2023, 01:08 PM
|
#9 |
|
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,966
|
wrong thread? 😅
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people |
|
|
02-14-2023, 01:09 PM
|
#10 |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
@mespotine
It in fact seems to initialize the project by adding extension data for cycle actions: Here is the diff log Code:
<EXTENSIONS
...
{ABEDA7BC-CA7A-46C8-9E8D-C94BFC0C241A} 0 "" "" ""
{28590BE8-97D4-4376-A63A-E965ACFB6190} 0 "" "" ""
{30766988-F13F-43D5-A090-E7CA2B3D3940} 0 "" "" ""
>
+ <S&M_CYCLACTIONS
+ 0 0 0 0
+ 0 1 0 0
+ 0 2 0 0
+ 0 3 0 0
+ 0 4 0 0
+ 0 5 0 0
+ 0 6 0 0
+ 0 7 0 0
+ >
>
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation |
|
|
02-14-2023, 01:10 PM
|
#11 |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
This means that on a saved project, the issue doesn't appear.
Code:
reaper.CountTrackMediaItems(reaper.GetTrack(0,0)) 🧐weird, it seems to only do that in first tab. For the other tab, even unsaved it doesnt display any undo point. EDIT: I removed my cycle action and it doesnt trigger the undo entry anymore.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation Last edited by X-Raym; 02-14-2023 at 01:15 PM. Reason: TABS |
|
|
02-14-2023, 01:15 PM
|
#12 | |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Quote:
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
|
02-14-2023, 01:27 PM
|
#13 |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Yes, the undo point will only be created when there is an "uncommitted" undo state that wasn't previously included in a block.
I think of it like git. Anything you "git add", will be included in your next commit ![]() Let's say you run a script that changes item selection, but doesn't create undo points using the defer trick. When you now run Code:
reaper.CountTrackMediaItems(reaper.GetTrack(0,0)) Unfortunately though, it's not just irresponsible coders messing up their undo blocks, REAPER has a lot of these "uncommitted" states by itself. Which is why the recommended approach by Justin doesn't work in practice. You can "put everything back into place", but if there are previous "uncommitted" changes.... you end up with an undo block. Nothing you can do about it (except using the defer trick).
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
02-14-2023, 01:52 PM
|
#14 | |
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,810
|
Quote:
(fixing the one from creating a new track, oops) Last edited by Justin; 02-14-2023 at 02:03 PM. |
|
|
|
02-14-2023, 02:19 PM
|
#15 | |
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,810
|
Quote:
They aren't doing anything -- if the reascript just does "x=1" then it wlil have the same behavior. Having said that, if you'd like, you can begin all of your ReaScripts with: Code:
reaper.Undo_OnStateChangeEx("Blame Canada",-1,-1)
This will let you make sure that any changes your script does are included in the "Run: ReaScript" block (which will be omitted if your script doesn't change anything), and any latent changes that were left around are categorized accordingly. |
|
|
|
02-14-2023, 02:54 PM
|
#16 | |
|
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,966
|
Quote:
Edit: here's my old bugreport https://forum.cockos.com/showthread.php?p=2517876
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people Last edited by Meo-Ada Mespotine; 02-14-2023 at 03:01 PM. |
|
|
|
02-14-2023, 05:00 PM
|
#17 | |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Quote:
Nice, that is the obvious one. Just in case you missed it, SHOWINMIX only occurs when the mixer is visible. Code:
- SHOWINMIX 1 0.6667 0.5 1 0.5 -1 -1 -1
+ SHOWINMIX 1 0.6667 0.5 1 0.5 0 -1 -1
REC 0 5088 1 0 0 0 0 0
VU 2
- TRACKHEIGHT 0 0 0 -1 -1 0
+ TRACKHEIGHT 0 0 0 0 -1 0
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
|
02-14-2023, 05:45 PM
|
#18 | |
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,810
|
Quote:
SetExtState can't possibly modify undo state. Just tested it -- it behaves exactly the same if you replace the script with a no-op "x=1". Do the blame canada method and there you go. Edit: hmm, actually, the API that extensions can use to register their state... that shouldn't be subject to the undo system, IMO. Project state set by scripts is already excluded. Last edited by Justin; 02-14-2023 at 06:24 PM. |
|
|
|
02-16-2023, 04:09 PM
|
#19 | |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Quote:
But there are several other such cases that produce spurious and erroneous undo history corruptions with "ReaScript: Run" and they have been reported many times here in the forum. But there seems to be some strong desire to ignore these obvious, long-standing, annoying, and continuing fundamental bugs. Not sure why. The principle is really very simple, if the internal state of a project has not changed (i.e. were the project to be saved out to its RPP file, nothing in the file would have changed), then there should be no undo history entry, end of story. Any behavior other than this is a corruption of the undo history. |
|
|
|
02-16-2023, 04:35 PM
|
#20 |
|
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,966
|
@Justsayin
Could you be a little more polite? Undo is difficult and in most cases I observed, no one posted the undo-state-information to get the actual added data that shouldn't be there. But if you know otherwise, well, post a link to these reports that show it more detailed, as it's otherwise damn difficult to find out about that. It took me days to figure out the SWS-Cyclactions-undo-issue as it was really difficult to tackle. Other such bugs might even be more difficult to trigger. It's easy to say "Undo is corrupted" but if that's the only information to work from, there's not much you can do with it. You need more details.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people |
|
|
02-16-2023, 06:22 PM
|
#21 |
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 17,822
|
|
|
|
02-17-2023, 12:53 AM
|
#22 |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
You are confusing corruption and alteration. Yes undo history is altered, cause it changed, but not corrupted, cause it still works. Corruption means data reading errors. It is not the case here.
We all agree that unecessary undo points should be erased. All is needed is propper bug reports. Rudeness isnt helpful in any way.
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation Last edited by X-Raym; 02-17-2023 at 05:33 AM. |
|
|
02-17-2023, 05:18 AM
|
#23 | |
|
Scribe
Join Date: Jan 2007
Location: Van Diemen's Land
Posts: 12,514
|
Quote:
But I fear that in this case youy are flogging a dead horse.
__________________
Learning Manuals and Reaper Books REAPER Unleashed - ReaMix - REAPER User Guide http://www.lulu.com/spotlight/glazfolk |
|
|
|
02-17-2023, 07:49 AM
|
#24 | |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Quote:
REAPER is a state machine. As @Justin and @Schwa have pointed out on several occasions, the Undo History is supposed to exclusively report when that internal state changes. If it contains entries reporting state changes that do not exist, then it is incorrect (aka "spurious" or "corrupted") and cannot be relied upon to accurately report state changes. With all due respect, I believe it is you who is misunderstanding here. |
|
|
|
02-17-2023, 07:59 AM
|
#25 |
|
Pixel Pusher
Join Date: Mar 2007
Location: Blighty
Posts: 5,506
|
Its not very fair to move the goalposts from 'corrupt' to 'incorrect' in a pointless effort to score semantic points against X-Raym who's not even using his native language.
Your VPN will only get you so far, we're not stupid. Be nice.
__________________
The House of White Tie |
|
|
02-17-2023, 08:12 AM
|
#26 | |
|
Human being with feelings
Join Date: May 2017
Location: Somewhere over the Rainbow
Posts: 6,966
|
Quote:
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - ReaGirl - a GuiLib for guis working for blind people |
|
|
|
02-17-2023, 08:30 AM
|
#27 |
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,842
|
|
|
|
02-17-2023, 08:31 AM
|
#28 |
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,842
|
English is not my native language, but even I understand that "corrupted" and "incorrect" are pretty much different words. Corrupted is kind of error and incorrect is just different value.
|
|
|
02-17-2023, 09:03 AM
|
#29 |
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 17,822
|
Putting aside the semantics, to be clear and restate what has already been said in this thread:
Every entry in the undo history represents a change in state from the previous entry. The undo history is not corrupted and the undo states are correct. The issue or bug in this case is that the undo states are not labeled correctly. Checking the entire project state is costly; it's effectively the same process as saving the project. So for efficiency, actions only update the undo history for the parts of the project state that they could possibly have affected. For example, moving a volume knob is not going to check the FX undo state. Occasionally, an action might change parts of the project state but not update the undo history completely. That's a bug, and we fix actions like that when we come across them. But when it happens, the latent or pending undo state is included in the next undo point that includes the same kinds of changes as the latent ones. "ReaScript: Run" by design checks all of the project undo state, so it effectively collects any pending undo changes. The obvious fix for this on our side is to check the project undo state before running the script as well as afterwards. The practical result will be that where currently a reascript that does not change the project state results in an occasional "ReaScript: Run" undo point, instead that undo point would be labeled something like "Undo: Sync". |
|
|
02-17-2023, 09:07 AM
|
#30 | |
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,842
|
Quote:
|
|
|
|
02-17-2023, 09:14 AM
|
#31 |
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 17,822
|
Not really, no.
|
|
|
02-17-2023, 09:51 AM
|
#32 | |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Quote:
Depending on how the undo system is designed, this might be close to impossible though. And maybe it's not a good idea to give us this power & responsibility ![]() I will say though, I have spent far too many hours tricking REAPER into not creating an undo point... Figuring out stuff like using: Code:
reaper.SetMediaTrackInfo_Value(track, 'I_SELECTED', 1) Code:
reaper.SetTrackSelected(track, true) So, if it's possible to add, please consider adding it.
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
|
02-17-2023, 10:13 AM
|
#33 | |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Quote:
|
|
|
|
02-17-2023, 10:16 AM
|
#34 | |
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 17,822
|
Quote:
|
|
|
|
02-17-2023, 10:26 AM
|
#35 |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
If that were true, then undoing the "ReaScript: Run" in the example given should cause a state change, and it does not.
|
|
|
02-17-2023, 10:35 AM
|
#36 |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
It does Mr. Cohler... right click on the undo list entry > Undo state information.
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
02-17-2023, 10:36 AM
|
#37 |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
In the example given at the top of this thread, there is just one track in the project. No items, no envelopes, no FX, no markers, nothing...
If you examine the track state chunk using Code:
reaper.GetTrackStateChunk |
|
|
02-17-2023, 10:41 AM
|
#38 | |
|
Human being with feelings
Join Date: May 2019
Location: Berlin
Posts: 2,568
|
Quote:
Btw, in the latest dev version, the above example does not create an undo point here.
__________________
Featured scripts: REAPER Update Utility Lil Chordbox Gridbox/Adaptive grid MX Tuner RS5K Link MIDI Editor Magic Donate💝: PayPal|ko-fi |
|
|
|
02-17-2023, 11:04 AM
|
#39 | |
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 11,147
|
@JustSayin
Quote:
__________________
Free ReaScripts - Premium Scripts - Custom Scripts Dev - Learn ReaScript - XR Theme - Stash Files - ReaLinks - ReaComics - Donation |
|
|
|
02-17-2023, 11:51 AM
|
#40 | |
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Quote:
|
|
|
|
![]() |
| Thread Tools | |
|
|