Tooldev: renoise.song() triggers error when executed during renoise startup

It seems that renoise does not have the renoise.song() function/object ready at startup, while tools that could access it are already being loaded. Executing that function before the startup/template song is loaded results in an error.

If a tool uses the function in it’s startup code the tool will fail loading, breaking the tool. However once renoise has successfully loaded, and tools are reloaded manually, the function works as expected, even when used in the startup code of the tool.

Expected behavior: either tools to be loaded once the renoise.song() function is ready for use, or the function passing a value like nil to indicate that the system is not ready yet.

I have created a little testing tool to demonstrate the error. Install the xrnx - it will print a message dialog stating success while being installed. Now shut down renoise. Start renoise again - the tool will execute renoise.song() and trigger the error message, the tool will not be loaded. Reloading the tools once renoise has finished startup will not trigger the error, but successfully load the tool and print the success message.

Tested with Renoise 3.3.2 on Linux.

song_object_bug.xrnx (602 Bytes)

Other (GUI) functionality seems to crap out as well when starting stuff directly when the tool loads.

Reason why I am doing it - I trigger the main function right at the end of the main.lua. So while I am developing, I can just fire up renoise and play around with the tool right away. Have to currently reload the tool for things to work properly.

May be possible to ‘wrap’ your ‘call’ to the ‘renoise.song()’ method;
thus ‘catching’ then ‘handling’ the failure in your own function.

I know this is not very convenient, but if you’re tool depends on the Renoise song, you anyway will need to listen for song instance changes via renoise.tool().app_new_document_observable

So you should avoid using Lua main and hook into either app_new_document_observable or renoise.tool().tool_finished_loading_observable depending on if your tool is working on the app itself only or on the app’s song document.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.