1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioDeviceSelectorComponent: Avoid assertions when recreating AudioDeviceSettingsPanel

This commit is contained in:
reuk 2023-09-20 18:35:32 +01:00
parent 3ee03cadd9
commit 42100c9341
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -213,8 +213,9 @@ class AudioDeviceSettingsPanel : public Component,
{
public:
AudioDeviceSettingsPanel (AudioIODeviceType& t, AudioDeviceSetupDetails& setupDetails,
const bool hideAdvancedOptionsWithButton)
: type (t), setup (setupDetails)
const bool hideAdvancedOptionsWithButton,
AudioDeviceSelectorComponent& p)
: type (t), setup (setupDetails), parent (p)
{
if (hideAdvancedOptionsWithButton)
{
@ -237,13 +238,11 @@ public:
}
void resized() override
{
if (auto* parent = findParentComponentOfClass<AudioDeviceSelectorComponent>())
{
Rectangle<int> r (proportionOfWidth (0.35f), 0, proportionOfWidth (0.6f), 3000);
const int maxListBoxHeight = 100;
const int h = parent->getItemHeight();
const int h = parent.getItemHeight();
const int space = h / 4;
if (outputDeviceDropDown != nullptr)
@ -348,11 +347,6 @@ public:
setSize (getWidth(), r.getY());
}
else
{
jassertfalse;
}
}
void updateConfig (bool updateOutputDevice, bool updateInputDevice, bool updateSampleRate, bool updateBufferSize)
{
@ -542,6 +536,7 @@ public:
private:
AudioIODeviceType& type;
const AudioDeviceSetupDetails setup;
AudioDeviceSelectorComponent& parent;
std::unique_ptr<ComboBox> outputDeviceDropDown, inputDeviceDropDown, sampleRateDropDown, bufferSizeDropDown;
std::unique_ptr<Label> outputDeviceLabel, inputDeviceLabel, sampleRateLabel, bufferSizeLabel, inputChanLabel, outputChanLabel;
@ -1156,7 +1151,7 @@ void AudioDeviceSelectorComponent::updateAllControls()
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;
audioDeviceSettingsComp = std::make_unique<AudioDeviceSettingsPanel> (*type, details, hideAdvancedOptionsWithButton);
audioDeviceSettingsComp = std::make_unique<AudioDeviceSettingsPanel> (*type, details, hideAdvancedOptionsWithButton, *this);
addAndMakeVisible (audioDeviceSettingsComp.get());
}
}