Skip to content

Commit ab87f0e

Browse files
authored
Merge pull request #13333 from ronso0/pref-mixer-deck-eq-fix
(fix) Pref Mixer: don't update EQs/QuickEffects while applying
2 parents bc17387 + 7ad2053 commit ab87f0e

2 files changed

Lines changed: 23 additions & 33 deletions

File tree

src/preferences/dialog/dlgprefmixer.cpp

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ DlgPrefMixer::DlgPrefMixer(
9393
m_gainAutoReset(false),
9494
m_eqBypass(false),
9595
m_initializing(true),
96-
m_updatingMainEQ(false) {
96+
m_updatingMainEQ(false),
97+
m_applyingDeckEQs(false),
98+
m_applyingQuickEffects(false) {
9799
setupUi(this);
98100

99101
// Update the crossfader curve graph and other settings when the
@@ -222,13 +224,12 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
222224
QOverload<int>::of(&QComboBox::currentIndexChanged),
223225
this,
224226
&DlgPrefMixer::slotEQEffectSelectionChanged);
225-
// Update the combobox in case the effect was changed from anywhere else
227+
// Update the combobox in case the effect was changed from anywhere else.
228+
// This will wipe pending EQ effect changes.
226229
connect(pEqEffectSlot.data(),
227230
&EffectSlot::effectChanged,
228231
this,
229-
[this]() {
230-
slotPopulateDeckEqSelectors();
231-
});
232+
&DlgPrefMixer::slotPopulateDeckEqSelectors);
232233

233234
// Create the QuickEffect selector /////////////////////////////////////
234235
auto pQuickEffectComboBox = make_parented<QComboBox>(this);
@@ -239,20 +240,13 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
239240
this,
240241
&DlgPrefMixer::slotQuickEffectSelectionChanged);
241242
// Update the combobox when the effect was changed in WEffectChainPresetSelector
242-
// or with controllers
243+
// or with controllers. This will wipe pending QuickEffect changes.
243244
EffectChainPointer pChain = m_pEffectsManager->getQuickEffectChain(deckGroup);
244245
DEBUG_ASSERT(pChain);
245-
// TODO(xxx) Connecting the signal to a lambda that capture the parented_ptr
246-
// pQuickEffectComboBox and sets the combobox index causes a crash in
247-
// applyQuickEffects() even though the signal hasn_t been emitted, yet.
248-
// Hence we just capture the deck group and the new preset's name and set
249-
// the index in a separate slot for now.
250246
connect(pChain.data(),
251247
&EffectChain::chainPresetChanged,
252248
this,
253-
[this, deckGroup](const QString& name) {
254-
slotQuickEffectChangedOnDeck(deckGroup, name);
255-
});
249+
&DlgPrefMixer::slotPopulateQuickEffectSelectors);
256250

257251
// Add the new widgets
258252
gridLayout_3->addWidget(pLabel, deckNo, 0);
@@ -276,6 +270,10 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
276270
}
277271

278272
void DlgPrefMixer::slotPopulateDeckEqSelectors() {
273+
if (m_applyingDeckEQs) {
274+
return;
275+
}
276+
279277
m_ignoreEqQuickEffectBoxSignals = true; // prevents a recursive call
280278

281279
const QList<EffectManifestPointer> pManifestList = getDeckEqManifests();
@@ -338,6 +336,9 @@ void DlgPrefMixer::slotPopulateDeckEqSelectors() {
338336
}
339337

340338
void DlgPrefMixer::slotPopulateQuickEffectSelectors() {
339+
if (m_applyingQuickEffects) {
340+
return;
341+
}
341342
m_ignoreEqQuickEffectBoxSignals = true;
342343

343344
QList<EffectChainPresetPointer> presetList =
@@ -423,12 +424,12 @@ void DlgPrefMixer::slotSingleEqToggled(bool checked) {
423424
for (int deck = 1; deck < m_deckEqEffectSelectors.size(); ++deck) {
424425
auto* eqBox = m_deckEqEffectSelectors[deck];
425426
eqBox->setEnabled(!m_eqBypass);
426-
slotPopulateDeckEqSelectors();
427427

428428
auto* quickBox = m_deckQuickEffectSelectors[deck];
429429
quickBox->setEnabled(true);
430-
slotPopulateQuickEffectSelectors();
431430
}
431+
slotPopulateDeckEqSelectors();
432+
slotPopulateQuickEffectSelectors();
432433
}
433434
}
434435

@@ -504,23 +505,8 @@ void DlgPrefMixer::slotQuickEffectSelectionChanged(int effectIndex) {
504505
}
505506
}
506507

507-
/// The Quick Effect was changed via the GUI or controls, update the combobox
508-
void DlgPrefMixer::slotQuickEffectChangedOnDeck(const QString& deckGroup,
509-
const QString& presetName) {
510-
int deck;
511-
if (PlayerManager::isDeckGroup(deckGroup, &deck)) {
512-
deck -= 1; // decks indices are 0-based
513-
auto* pBox = m_deckQuickEffectSelectors[deck];
514-
VERIFY_OR_DEBUG_ASSERT(pBox) {
515-
return;
516-
}
517-
pBox->blockSignals(true);
518-
pBox->setCurrentIndex(pBox->findText(presetName));
519-
pBox->blockSignals(false);
520-
}
521-
}
522-
523508
void DlgPrefMixer::applyDeckEQs() {
509+
m_applyingDeckEQs = true;
524510
m_ignoreEqQuickEffectBoxSignals = true;
525511

526512
for (int deck = 0; deck < m_deckEqEffectSelectors.size(); deck++) {
@@ -560,9 +546,11 @@ void DlgPrefMixer::applyDeckEQs() {
560546
}
561547
}
562548
m_ignoreEqQuickEffectBoxSignals = false;
549+
m_applyingDeckEQs = false;
563550
}
564551

565552
void DlgPrefMixer::applyQuickEffects() {
553+
m_applyingQuickEffects = true;
566554
m_ignoreEqQuickEffectBoxSignals = true;
567555

568556
for (int deck = 0; deck < m_deckQuickEffectSelectors.size(); deck++) {
@@ -593,6 +581,7 @@ void DlgPrefMixer::applyQuickEffects() {
593581
}
594582
}
595583
m_ignoreEqQuickEffectBoxSignals = false;
584+
m_applyingQuickEffects = false;
596585
}
597586

598587
void DlgPrefMixer::slotHiEqSliderChanged() {

src/preferences/dialog/dlgprefmixer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class DlgPrefMixer : public DlgPreferencePage, public Ui::DlgPrefMixerDlg {
3333
void slotNumDecksChanged(double numDecks);
3434
void slotEQEffectSelectionChanged(int effectIndex);
3535
void slotQuickEffectSelectionChanged(int effectIndex);
36-
void slotQuickEffectChangedOnDeck(const QString& group, const QString& presetName);
3736
void slotEqOnlyToggled(bool checked);
3837
void slotSingleEqToggled(bool checked);
3938
void slotEqAutoResetToggled(bool checked);
@@ -115,6 +114,8 @@ class DlgPrefMixer : public DlgPreferencePage, public Ui::DlgPrefMixerDlg {
115114

116115
bool m_initializing;
117116
bool m_updatingMainEQ;
117+
bool m_applyingDeckEQs;
118+
bool m_applyingQuickEffects;
118119

119120
QList<int> m_eqIndiciesOnUpdate;
120121
QList<int> m_quickEffectIndiciesOnUpdate;

0 commit comments

Comments
 (0)