Skip to content

Commit

Permalink
ControlIndicatorTimer: Remove unnecessary member variable
Browse files Browse the repository at this point in the history
The `m_toggleIndicator500millisOnNextTimeout` can be removed, because
the 500ms indicator just needs to be toggled on every second toggle of
the 250ms indicator.
  • Loading branch information
Holzhaus committed Jul 30, 2021
1 parent e67bb4c commit b891a96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/control/controlindicatortimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ ControlIndicatorTimer::ControlIndicatorTimer(QObject* pParent)
m_pCOIndicator250millis(std::make_unique<ControlObject>(
ConfigKey("[Master]", "indicator_250millis"))),
m_pCOIndicator500millis(std::make_unique<ControlObject>(
ConfigKey("[Master]", "indicator_500millis"))),
m_toggleIndicator500millisOnNextTimeout(true) {
ConfigKey("[Master]", "indicator_500millis"))) {
m_pCOIndicator250millis->setReadOnly();
m_pCOIndicator500millis->setReadOnly();
connect(&m_timer, &QTimer::timeout, this, &ControlIndicatorTimer::slotTimeout);
Expand All @@ -20,13 +19,13 @@ ControlIndicatorTimer::ControlIndicatorTimer(QObject* pParent)

void ControlIndicatorTimer::slotTimeout() {
// The timeout uses an interval of 250ms, so the 250ms indicator is always updated.
m_pCOIndicator250millis->forceSet(m_pCOIndicator250millis->toBool() ? 0.0 : 1.0);
const bool indicator250millisEnabled = m_pCOIndicator250millis->toBool();
m_pCOIndicator250millis->forceSet(indicator250millisEnabled ? 0.0 : 1.0);

// The 500ms indicator is only updated on every second call to the function.
if (m_toggleIndicator500millisOnNextTimeout) {
if (indicator250millisEnabled) {
m_pCOIndicator500millis->forceSet(m_pCOIndicator500millis->toBool() ? 0.0 : 1.0);
}
m_toggleIndicator500millisOnNextTimeout = !m_toggleIndicator500millisOnNextTimeout;
}

} // namespace mixxx
1 change: 0 additions & 1 deletion src/control/controlindicatortimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class ControlIndicatorTimer : public QObject {
QTimer m_timer;
std::unique_ptr<ControlObject> m_pCOIndicator250millis;
std::unique_ptr<ControlObject> m_pCOIndicator500millis;
bool m_toggleIndicator500millisOnNextTimeout;
};

} // namespace mixxx

0 comments on commit b891a96

Please sign in to comment.