Prev Previous Post   Next Post Next
Old 04-02-2018, 12:52 PM   #11
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554

How do I execute some code at the project load/switch?

I was using fixed arrays of 1024 elements to store tracks data (mute/pan/vol/etc) and decided to switch to vector of objects, with a single object for each track, containing the necessary data.
I've also added a resize vector method into the Run() function and in every function, that is called by Reaper (there are bunch of them already in the example).
It was going fine until I've tried to load an existing project. Reaper then crashed with vector subscript out of range error.
I guess, resize should also be executed at the project loading or switching to another project's tab, but I don't know ho do I track it. Any help would be appreciated.

UPD. For some unknown reason, Reaper was calling track related function even when there weren't any tracks in the project, so it was giving the track number -1, which lead to crash, when the plugin tried to write track's vol/pan/etc state into the vector at index '-1'.
I don't know why does reaper_plugin.h calls those functions for track -1, so I've simply added a check, if the tracks number is zero or positive.

Last edited by fundorin; 04-02-2018 at 01:41 PM.
fundorin is offline   Reply With Quote

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 03:46 AM.

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