Page 1 of 1

getTemporaryCopy parameter count

PostPosted: Sun Oct 01, 2017 3:53 pm
by TIV73
Hi everybody,
it looks like (one of) the latest public revision(s) changed how getTemporaryCopy works. Previously, I could do something like this:
Code: Select all
var currentTrack = app.player.getCurrentTrack();
var copy = currentTrack.getTemporaryCopy();

Now I'm just getting a wrong parameter count error when trying that. Other than this, which doesn't say anything about any parameters I couldn't find any examples or documentation, so I'm a bit lost on how to use the function.
I suppose I could use getTemporaryCopies instead, but wrapping a track it in a tracklist, making a copy of said list and finally extracting a copy of the original track seems kinda hacky if I only have one track to begin with.

So, does anybody have any hints on how to use getTemporaryCopy or any other method to copy a track object that doesn't just return a reference to the original object but actually creates a new one?

Having a look at my original function, maybe I'm overthinking this:

Code: Select all
if (track.artist !== newArtist) {
   let newTrack = track.getTemporaryCopy()
   newTrack.artist = newArtist

I wrote this some time ago, so I probably just copied it from some example I found. Is there any actual benefit to cloning the object, changing a single property and then assigning the copy back to the original - I mean as opposed to just changing the property? It's probably handy if you change a couple of attributes and want to avoid having to compare every single property to update the original object, but in this case it's maybe just a waste of resources.

Edit 2:
Yes, just assigning a new value to track.artist works fine and doesn't have any negative side effects (that I could find), so I'll just use that. Out of curiosity I sill wonder how getTemporaryCopy should be used, though.

Re: getTemporaryCopy parameter count

PostPosted: Mon Oct 02, 2017 12:16 am
by PetrCBR
Hi. It's regression ... thanks for the report.

Re: getTemporaryCopy parameter count

PostPosted: Mon Oct 02, 2017 5:49 am
by TIV73
I didn't think about that option. Thanks a lot for letting me know!