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

Reply
 
Thread Tools Display Modes
Old 10-15-2018, 08:51 PM   #1
Moy
Human being with feelings
 
Moy's Avatar
 
Join Date: Oct 2017
Location: China
Posts: 32
Default [5.96] Crash when using “SetMediaItemTake_Source” function (FIXED)

[Steps How to Reproduce]
1. Open a Project with at least 1 item.
2. Run this Script:

--

-- Get other information
local pos = reaper.GetCursorPosition()

-- Get information from an item
item = reaper.GetMediaItem(0, 0)

item_sel = reaper.GetSelectedMediaItem(0, 0)
item = item_sel

take = reaper.GetMediaItemTake(item, 0)
take_num = reaper.GetMediaItemNumTakes(item)

file = reaper.GetMediaItemTake_Source(take)
length = reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
track = reaper.GetMediaItemTrack(item)

-- Create new item based on the first one
item_new = reaper.AddMediaItemToTrack(track)
reaper.SetMediaItemInfo_Value(item_new, "D_LENGTH", length)
reaper.SetMediaItemInfo_Value(item_new, "D_POSITION", pos)

take_new = reaper.AddTakeToMediaItem(item_new)
Msg(reaper.GetMediaItemNumTakes(item_new))

-- [!] WHEN DOING THIS, REAPER WILL CRASH
reaper.SetMediaItemTake_Source(take_new, file)

reaper.UpdateArrange()

--

It could set the source to new take, but after a while(1 or 2 seconds), reaper will crash.
Some times with this ERROR:

[Microsoft Visual C++ Runtime Library]

Runtime Error!
Program: D:\Apps\REAPER\reaper.exe

R6025
- pure virtual function call
Attached Images
File Type: png ERROR.png (5.0 KB, 15 views)

Last edited by Moy; 10-15-2018 at 08:57 PM.
Moy is offline   Reply With Quote
Old 10-16-2018, 03:38 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,454
Default

You must not get a PCM_source (the "file") from a take and then set it on another take. That does not result in a copy of the PCM_source in the destination take but rather makes both takes reference the same PCM_source, which is not going to work. So it's not strictly speaking a bug in Reaper but the script code doing things it should not do. But maybe Reaper could do some sanity check in the scripting implementation to prevent that from happening...

The scripting API appears to be missing a way to duplicate PCM_sources which would be a useful addition for use cases like this.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 10-16-2018 at 03:50 AM.
Xenakios is offline   Reply With Quote
Old 10-16-2018, 04:59 AM   #3
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,689
Default

Yeah, we need to add a PCM_Source_Duplicate() and have SetMediaItemTake_Source() check to make sure that the current source is not referenced elsewhere in any project...

Or maybe SetMediaItemTake_Source() should just auto-duplicate if necessary, that might be better.
Justin is offline   Reply With Quote
Old 10-16-2018, 05:07 AM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,454
Default

Quote:
Originally Posted by Justin View Post
Or maybe SetMediaItemTake_Source() should just auto-duplicate if necessary, that might be better.
PCM_Source_Duplicate would be fun to have anyway, though...(Assuming ReaScript code can do anything interesting with the duplicated source anyway, maybe there isn't any use case...?)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is offline   Reply With Quote
Old 10-16-2018, 05:47 AM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,689
Default

Quote:
Originally Posted by Xenakios View Post
PCM_Source_Duplicate would be fun to have anyway, though...(Assuming ReaScript code can do anything interesting with the duplicated source anyway, maybe there isn't any use case...?)
Not sure what you could do that SetMediaItemTake_Source() auto-duplicating wouldn't already do?
Justin 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 04:41 AM.


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