Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 01-19-2021, 11:35 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default API InsertAutomationItem creates its own undo = cant catch with Undo_OnStateChange




Test code:
Code:
env = reaper.GetSelectedEnvelope( 0 )

if env then
  -- create AI
  ai = reaper.InsertAutomationItem( env, 0, 4, 6 )
  -- move AI somewhere else
  reaper.GetSetAutomationItemInfo( env, ai, "D_POSITION", 12, true )
  -- create Undo
  reaper.Undo_OnStateChangeEx( "bla", 1, -1 )
else
  return
end

Undoing does not return to original state before running the script but to the insertion of the AI point.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-23-2021, 02:31 AM   #2
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I would be very grateful if this was fixed as it messes the undo point creation of a script of mine. Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 01-23-2021, 07:50 AM   #3
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

see Undo_BeginBlock()/Undo_EndBlock()
Justin is offline   Reply With Quote
Old 01-23-2021, 08:02 AM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I use these APIs in run-once scripts but they are not so useful in deferred scripts because they will create an undo point even if there was not any change... Is it tricky to make InsertAutomationItem not create a separate undo point?

Or how could I avoid creating an undo point after calling Undo_BeginBlock if nothing has changed?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 01-24-2021 at 06:46 AM.
amagalma is offline   Reply With Quote
Old 01-24-2021, 06:50 AM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I have to pay more attention to what the Reaper devs themselves propose!


Problem solved!.. I can track if there has been a change while the script is deferred and call BeginUndo when and if needed.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.