|
|
|
10-15-2018, 07:04 PM
|
#1
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
A Lua script that can make reaper CRASH
I tried to creat a script to make a new mediaitem at edit cursor base on a exist item
Code:
--Get information from an item
item=reaper.GetMediaItem(0,0)
take=reaper.GetMediaItemTake(item,0)
file=reaper.GetMediaItemTake_Source(take)
length=reaper.GetMediaItemInfo_Value(item,"D_LENGTH")
pos=reaper.GetCursorPosition()
track=reaper.GetMediaItemTrack(item)
--Creat new item base on the first one
itemnew=reaper.AddMediaItemToTrack(track)
reaper.SetMediaItemInfo_Value(itemnew,"D_LENGTH",length)
reaper.SetMediaItemInfo_Value(itemnew,"D_POSITION",pos)
takenew=reaper.AddTakeToMediaItem(itemnew)
reaper.SetMediaItemTake_Source(takenew,file)
reaper.UpdateArrange()
It worked actually, created a new mediaitem exactly the same as the original one. But then I try to delete any of them, either the original one or the new one, reaper CRASH, and showed a warning message like this:
Anybody can tell me what's wrong with the script?
|
|
|
10-15-2018, 08:31 PM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
This is a Reaper-Bug and needs to be fixed by the devs themselves.
In addition to your script, can you post the project itself as well?
Run the script to create the duplication of the items(without deleting them!) and save the project.
Post that RPP-File to your post to give insight, what is happening in your project.
This could be helpful for the devs to bugfix it.
Another thing, everytime Reaper crashes, you should post into the Bug Reports-subforum, so the devs don't miss your bugreport accidentally.
Which Reaper-version and which Operating-System-version are you using?
Edit: I can confirm this crash on Windows 7Pro with Reaper 5.96 and SWS 2.97
|
|
|
10-15-2018, 08:52 PM
|
#3
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Until the bug is fixed, you can use this function to help you do the copying.
Code:
function CopyItemToPosition(track, item, position)
retval, statechunk=reaper.GetItemStateChunk(item,"",false)
newitem = reaper.AddMediaItemToTrack(track)
reaper.SetItemStateChunk(newitem, statechunk, false)
reaper.SetMediaItemPosition(newitem, 10, false)
return item
end
CopyItemToPosition(reaper.GetTrack(0,1), reaper.GetMediaItem(0,0), 20)
-- first parameter the track,
-- second parameter is the MediaItem to create a copy from
-- third parameter, the position in seconds
--
-- it returns the newly created item
|
|
|
10-15-2018, 10:55 PM
|
#4
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,598
|
its not a bug,you cannot use file name (source) directly
Code:
filename=reaper.GetMediaSourceFileName(source, "")
clonedsource=reaper.PCM_Source_CreateFromFile(filename)
reaper.SetMediaItemTake_Source(take, clonedsource)
|
|
|
10-16-2018, 08:24 PM
|
#5
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Sexan
its not a bug,you cannot use file name (source) directly
Code:
filename=reaper.GetMediaSourceFileName(source, "")
clonedsource=reaper.PCM_Source_CreateFromFile(filename)
reaper.SetMediaItemTake_Source(take, clonedsource)
|
Yes, that's the big mistake in my script. I fixed that according to your advise, and then it worked! Thank you so much!
|
|
|
10-16-2018, 08:25 PM
|
#6
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by mespotine
Until the bug is fixed, you can use this function to help you do the copying.
Code:
function CopyItemToPosition(track, item, position)
retval, statechunk=reaper.GetItemStateChunk(item,"",false)
newitem = reaper.AddMediaItemToTrack(track)
reaper.SetItemStateChunk(newitem, statechunk, false)
reaper.SetMediaItemPosition(newitem, 10, false)
return item
end
CopyItemToPosition(reaper.GetTrack(0,1), reaper.GetMediaItem(0,0), 20)
-- first parameter the track,
-- second parameter is the MediaItem to create a copy from
-- third parameter, the position in seconds
--
-- it returns the newly created item
|
Maybe I misunderstanding about the correct way of using the function "GetMediaSourceFileName"
|
|
|
10-16-2018, 08:26 PM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
It's still a Reaper bug in the sense that the API functions shouldn't be able to crash it because you gave it the wrong value.
|
|
|
10-16-2018, 11:04 PM
|
#8
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,598
|
then I guess it is not easy to fix since this issue was brought up few times before and I even had discussion with scwha about it on PM
|
|
|
10-17-2018, 12:02 AM
|
#9
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
|
|
|
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:45 AM.
|