Crashing when rendering on a separate thread and also using the master track level measurer

I am hitting a segfault when rendering my edit on a separate thread using:

            "Render", renderFile, edit, range, tracksToDo, true, {}, true);

The last argument is the useThread boolean which ive set to true.

I have a component that consumes a level measurer object:

LevelMeterComponent::LevelMeterComponent(tracktion_engine::LevelMeasurer &lm,
                                         int chan)
    : channel(chan), levelMeasurer(lm) {

and I create the component like so and pass in the master track levels:

                    t->edit.getCurrentPlaybackContext()->masterLevels, 0)

however this causes a segfault when rendering on a separate thread when it calls the addClient method of the measurer. This ONLY happens with the master levels. If I use a regular tracks measurer like this:


things work fine. Things also work fine if I render on the main thread instead. It makes me think I am not using the correct way of obtaining the level measurer for the master track, and that I am running into some thread safety issue with the master measurer object. Is there a better way of getting it other than t->edit.getCurrentPlaybackContext()->masterLevels?

I was improperly listening to track changes causes my level meter to constantly be recreated. I changed that so that the constructor is no longer called like that all the time (like during a render) and things work ok. I do think there may be some thread related issues with the level meter client and the mutexes it uses still though, but the problem is no longer affecting me.