Skip to content

Commit

Permalink
Merge pull request #3712 from ksoze95/audio_setup_crash
Browse files Browse the repository at this point in the history
Fixed audio setup startup crash.
  • Loading branch information
ksoze95 committed Sep 28, 2022
2 parents 0f2a5ed + 7441bd1 commit cb08712
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/toolbars/AudioSetupToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,18 @@ void AudioSetupToolBar::UpdatePrefs()
}
}

long oldChannels;
long oldChannels = 0;
for (const auto & item : mInputChannels->GetMenuItems()) {
if (item->IsChecked())
oldChannels = item->GetId() - kInputChannels + 1;
}

auto newChannels = AudioIORecordChannels.ReadWithDefault(0);
if (newChannels > 0 && oldChannels != newChannels)
mInputChannels->FindChildItem(kInputChannels + newChannels - 1)->Check();
if (newChannels > 0 && oldChannels != newChannels) {
auto item = mInputChannels->FindChildItem(kInputChannels + newChannels - 1);
if (item != nullptr)
item->Check();
}

selectedHost = GetSelectedRadioItemLabel(*mHost);
if (!hostName.empty() && selectedHost && selectedHost != hostName) {
Expand Down Expand Up @@ -624,7 +627,9 @@ void AudioSetupToolBar::FillInputChannels()
newChannels = oldChannels;
}
if (newChannels >= 1) {
mInputChannels->FindItem(kInputChannels + newChannels - 1)->Check();
auto item = mInputChannels->FindItem(kInputChannels + newChannels - 1);
if (item != nullptr)
item->Check();
}
AudioIORecordChannels.Write(newChannels);
break;
Expand Down

0 comments on commit cb08712

Please sign in to comment.