Skip to content

Commit

Permalink
Merge pull request #13009 from acolombier/fix/qml-waveform-crash
Browse files Browse the repository at this point in the history
fix(QML): handle case where Waveform data is missing
  • Loading branch information
Holzhaus authored Mar 27, 2024
2 parents b2bec36 + d7d0d60 commit 0c34f90
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/qml/qmlplayerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,19 @@ void QmlPlayerProxy::slotWaveformChanged() {
emit waveformTextureStrideChanged();

const TrackPointer pTrack = m_pCurrentTrack;
if (pTrack) {
const ConstWaveformPointer pWaveform = pTrack->getWaveform();
const int textureWidth = pWaveform->getTextureStride();
const int textureHeight = pWaveform->getTextureSize() / pWaveform->getTextureStride();
if (pWaveform) {
const uchar* data = reinterpret_cast<const uchar*>(pWaveform->data());
m_waveformTexture = QImage(data, textureWidth, textureHeight, QImage::Format_RGBA8888);
emit waveformTextureChanged();
}
if (!pTrack) {
return;
}
const ConstWaveformPointer pWaveform =
pTrack->getWaveform();
if (!pWaveform) {
return;
}
const int textureWidth = pWaveform->getTextureStride();
const int textureHeight = pWaveform->getTextureSize() / pWaveform->getTextureStride();
const uchar* data = reinterpret_cast<const uchar*>(pWaveform->data());
m_waveformTexture = QImage(data, textureWidth, textureHeight, QImage::Format_RGBA8888);
emit waveformTextureChanged();
}

void QmlPlayerProxy::slotBeatsChanged() {
Expand Down

0 comments on commit 0c34f90

Please sign in to comment.