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

Avoid redundant messages for failed track load #10889

Merged
merged 2 commits into from
Sep 21, 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
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();
daschuer marked this conversation as resolved.
Show resolved Hide resolved
}

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