Skip to content

Commit

Permalink
Merge pull request #10889 from ronso0/failed-track-load-message
Browse files Browse the repository at this point in the history
Avoid redundant messages for failed track load
  • Loading branch information
daschuer authored Sep 21, 2022
2 parents d316b0d + 3f5d65f commit fc176e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ BaseTrackPlayerImpl::BaseTrackPlayerImpl(QObject* pParent,
m_pConfig(pConfig),
m_pEngineMaster(pMixingEngine),
m_pLoadedTrack(),
m_pPrevFailedTrackId(),
m_replaygainPending(false),
m_pChannelToCloneFrom(nullptr) {
ChannelHandleAndGroup channelGroup =
Expand Down Expand Up @@ -415,8 +416,19 @@ void BaseTrackPlayerImpl::slotLoadFailed(TrackPointer pTrack, const QString& rea
qDebug() << "Failed to load track (NULL track object)" << reason;
}
m_pChannelToCloneFrom = nullptr;

// Alert user.
// The QMessageBox blocks the event loop (and the GUI since it's modal dialog),
// though if a controller's Load button was pressed repeatedly we may get
// multiple identical messages for the same track.
// Avoid this and show only one message per track track at a time.
if (pTrack && m_pPrevFailedTrackId == pTrack->getId()) {
return;
} else if (pTrack) {
m_pPrevFailedTrackId = pTrack->getId();
}
QMessageBox::warning(nullptr, tr("Couldn't load track."), reason);
m_pPrevFailedTrackId = TrackId();
}

void BaseTrackPlayerImpl::slotTrackLoaded(TrackPointer pNewTrack,
Expand Down
2 changes: 2 additions & 0 deletions src/mixer/basetrackplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "preferences/usersettings.h"
#include "track/replaygain.h"
#include "track/track_decl.h"
#include "track/trackid.h"
#include "util/color/rgbcolor.h"
#include "util/memory.h"
#include "util/parented_ptr.h"
Expand Down Expand Up @@ -111,6 +112,7 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
UserSettingsPointer m_pConfig;
EngineMaster* m_pEngineMaster;
TrackPointer m_pLoadedTrack;
TrackId m_pPrevFailedTrackId;
EngineDeck* m_pChannel;
bool m_replaygainPending;
EngineChannel* m_pChannelToCloneFrom;
Expand Down

0 comments on commit fc176e4

Please sign in to comment.