Hi everyone!
My AudioProcessor
has an Unlocker
class that handles the license checking and plugin activation. It basically checks if the license file is present in a specific directory and, if not, it pops up a file selector for the user to choose the license file.
My AudioProcessorEditor
has an InfoPanel
class, a separate Component
that can be accessed when clicking on the company logo, that displays some info. Included in the displayed info, there is some user data extracted from the license file and passed to the InfoPanel
in its constructor.
When the plugin is already activated everything works as expected: the AudioProcessorEditor
is constructed with the user data already known that can be displayed in the InfoPanel
.
When the the plugin is activated for the first time, by choosing the license file through the file selector, the AudioProcessorEditor
needs to be re-constructed (hence the UI window needs to be closed and re-opened) before the correct user data is displayed.
This is of course not optimal, so I’m trying to find a way to set the correct user info in the InfoPanel
without needing to restart the plugin UI.
What’s the best approach to do this?
For now, I managed by having a pointer to the InfoPanel stored in the Unlocker
class that gets passed when calling createEditor()
:
juce::AudioProcessorEditor* PluginAudioProcessor::createEditor()
{
auto editor = new WrappedPluginAudioProcessorEditor (*this, m_unlocker.getUserInfo());
m_unlocker.setInfoPanel(editor->getInfoPanel());
return editor;
}
and, when the correct license file is selected, I call something like
if(m_infoPanel)
m_infoPanel->setUserInfo(m_userInfo);
from the Unlocker
class, to set the correct user info to be displayed.
I haven’t managed to crash the plugin yet (I guess because the file selector gets called when the editor already exists), but this is of course wrong since references to the editor’s Component
shouldn’t be stored in the processor.
The if(m_infoPanel)
protects from the pointer to the InfoPanel
being null, but not from it being dangling.
What are the alternatives here?
The only other solutions I can think of are:
-
Call the parent’s
getActivedEditor()
from theUnlocker
class when the correct license file is selected and, from that, set the correct info in theInfoPanel
if any editor is active. -
Use a
Timer
in theInfoPanel
that periodically fetches the correct info from theAudioProcessor
’sUnlocker
.
Thanks!