It repaints nothing (I need to close/reopen the plugin GUI to refresh data).
Should I pass to the TimerRepaint class a reference of the AudioPluginAudioProcessorEditor? (which I prefer to avoid, keeping separations between roles and objects…)
Still, I still see “glitch” on the label I print on the GUI, such as “weird” symbols printed for few ms. Even it that labelToDisplay is valued only in the processBlock’s audio function. What’s wrong?
It’s likely a thread race, the string is partway through being updated when the repaint occurs.
It would be better not constructing the string in the processor, but just storing the value in an atomic and then pull that in and construct the string in paint.
If the object is created and destroyed on the Message thread it should be fine, if it’s not, there is a risk that a callback occurs during destruction, after (or during) the destruction of the derived class but before the destruction of the Timer base class. If this happens you’re in undefined behaviour territory! In general I would suggest it’s good practice to always call stopTimer() in the destructor of the derived class.
There is a jassert in the Timer destructor to try and catch misuse, unfortunately what I sometimes see is something like this…
class MyClass : private juce::Timer
{
public:
MyClass() { startTimer (1); }
void timerCallback() override
{
stopTimer();
// do something on the message thread
}
}
The issue here is that the timer will have been stopped in MOST cases, but there is a rare chance of a bug, in this case it might happen during a scan of a plugin, potentially causing a hard to track bug that causes a plugin to get black listed.