Skip to content

Commit

Permalink
Merge pull request #2527 from uklotzde/2.2_wtracktableview
Browse files Browse the repository at this point in the history
Add missing nullptr checks
  • Loading branch information
Holzhaus authored Mar 1, 2020
2 parents cc43a2d + 4fa08ea commit adb2c3c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,9 @@ void WTrackTableView::slotMouseDoubleClicked(const QModelIndex &index) {
}

TrackPointer pTrack = trackModel->getTrack(index);
VERIFY_OR_DEBUG_ASSERT(pTrack) {
return;
if (pTrack) {
emit loadTrack(pTrack);
}

emit(loadTrack(pTrack));
} else if (doubleClickAction == DlgPrefLibrary::ADD_TO_AUTODJ_BOTTOM
&& modelHasCapabilities(TrackModel::TRACKMODELCAPS_ADDTOAUTODJ)) {
sendToAutoDJ(PlaylistDAO::AutoDJSendLoc::BOTTOM);
Expand Down Expand Up @@ -1811,13 +1809,11 @@ void WTrackTableView::slotScaleBpm(int scale) {

QModelIndexList selectedTrackIndices = selectionModel()->selectedRows();
for (const auto& index : selectedTrackIndices) {
TrackPointer track = trackModel->getTrack(index);
if (!track->isBpmLocked()) { // bpm is not locked
BeatsPointer beats = track->getBeats();
if (beats != nullptr) {
beats->scale(static_cast<Beats::BPMScale>(scale));
} else {
continue;
TrackPointer pTrack = trackModel->getTrack(index);
if (pTrack && !pTrack->isBpmLocked()) {
BeatsPointer pBeats = pTrack->getBeats();
if (pBeats) {
pBeats->scale(static_cast<Beats::BPMScale>(scale));
}
}
}
Expand All @@ -1832,8 +1828,10 @@ void WTrackTableView::lockBpm(bool lock) {
QModelIndexList selectedTrackIndices = selectionModel()->selectedRows();
// TODO: This should be done in a thread for large selections
for (const auto& index : selectedTrackIndices) {
TrackPointer track = trackModel->getTrack(index);
track->setBpmLocked(lock);
TrackPointer pTrack = trackModel->getTrack(index);
if (pTrack) {
pTrack->setBpmLocked(lock);
}
}
}

Expand All @@ -1846,9 +1844,9 @@ void WTrackTableView::slotClearBeats() {
QModelIndexList selectedTrackIndices = selectionModel()->selectedRows();
// TODO: This should be done in a thread for large selections
for (const auto& index : selectedTrackIndices) {
TrackPointer track = trackModel->getTrack(index);
if (!track->isBpmLocked()) {
track->setBeats(BeatsPointer());
TrackPointer pTrack = trackModel->getTrack(index);
if (pTrack && !pTrack->isBpmLocked()) {
pTrack->setBeats(BeatsPointer());
}
}
}
Expand Down

0 comments on commit adb2c3c

Please sign in to comment.