Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more null checks in WWaveformViewer #10960

Merged
merged 4 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/track/serato/beatgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ QDebug operator<<(QDebug dbg, const SeratoBeatGridTerminalMarker& arg);
/// https://github.com/Holzhaus/serato-tags/blob/master/docs/serato_beatgrid.md
class SeratoBeatGrid final {
public:
SeratoBeatGrid() = default;
SeratoBeatGrid()
: m_footer(0),
m_extraBase64Byte('A') {
}
SeratoBeatGrid(
SeratoBeatGridTerminalMarkerPointer pTerminalMarker,
QList<SeratoBeatGridNonTerminalMarkerPointer> nonTerminalMarkers)
: m_pTerminalMarker(pTerminalMarker),
: m_pTerminalMarker(std::move(pTerminalMarker)),
m_nonTerminalMarkers(std::move(nonTerminalMarkers)),
m_footer(0),
m_extraBase64Byte('A') {
Expand Down
12 changes: 12 additions & 0 deletions src/waveform/renderers/waveformwidgetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,15 @@ WaveformMarkPointer WaveformWidgetRenderer::getCueMarkAtPoint(QPoint point) cons
}
return nullptr;
}

CuePointer WaveformWidgetRenderer::getCuePointerFromIndex(int cueIndex) const {
if (cueIndex != Cue::kNoHotCue && m_pTrack) {
const QList<CuePointer> cueList = m_pTrack->getCuePoints();
for (const auto& pCue : cueList) {
if (pCue->getHotCue() == cueIndex) {
return pCue;
}
}
}
return {};
}
4 changes: 3 additions & 1 deletion src/waveform/renderers/waveformwidgetrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class WaveformWidgetRenderer {
const QString& getGroup() const {
return m_group;
}
const TrackPointer getTrackInfo() const {
const TrackPointer& getTrackInfo() const {
return m_pTrack;
}
/// Get cue mark at a point on the waveform widget.
WaveformMarkPointer getCueMarkAtPoint(QPoint point) const;

CuePointer getCuePointerFromIndex(int cueIndex) const;

double getFirstDisplayedPosition() const {
return m_firstDisplayedPosition;
}
Expand Down
18 changes: 8 additions & 10 deletions src/widget/wwaveformviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,10 @@ void WWaveformViewer::setWaveformWidget(WaveformWidgetAbstract* waveformWidget)
}

CuePointer WWaveformViewer::getCuePointerFromCueMark(WaveformMarkPointer pMark) const {
if (pMark && pMark->getHotCue() != Cue::kNoHotCue) {
const QList<CuePointer> cueList = m_waveformWidget->getTrackInfo()->getCuePoints();
for (const auto& pCue : cueList) {
if (pCue->getHotCue() == pMark->getHotCue()) {
return pCue;
}
}
if (m_waveformWidget && pMark) {
return m_waveformWidget->getCuePointerFromIndex(pMark->getHotCue());
}
return CuePointer();
return {};
}

void WWaveformViewer::highlightMark(WaveformMarkPointer pMark) {
Expand All @@ -281,8 +276,11 @@ void WWaveformViewer::highlightMark(WaveformMarkPointer pMark) {
}

void WWaveformViewer::unhighlightMark(WaveformMarkPointer pMark) {
QColor originalColor = mixxx::RgbColor::toQColor(getCuePointerFromCueMark(pMark)->getColor());
pMark->setBaseColor(originalColor, m_dimBrightThreshold);
auto pCue = getCuePointerFromCueMark(pMark);
if (pCue) {
QColor originalColor = mixxx::RgbColor::toQColor(pCue->getColor());
pMark->setBaseColor(originalColor, m_dimBrightThreshold);
}
}

bool WWaveformViewer::isPlaying() const {
Expand Down