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

SetLogFeature: Reset pointer when WLibrary is destroyed #3940

Merged
merged 3 commits into from
Jun 4, 2021
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
31 changes: 18 additions & 13 deletions src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ SetlogFeature::SetlogFeature(
/*keep deleted tracks*/ true),
QStringLiteral("SETLOGHOME")),
m_playlistId(kInvalidPlaylistId),
m_libraryWidget(nullptr),
m_icon(QStringLiteral(":/images/library/ic_library_history.svg")) {
// clear old empty entries
ScopedTransaction transaction(pLibrary->trackCollectionManager()
Expand Down Expand Up @@ -91,7 +90,7 @@ void SetlogFeature::bindLibraryWidget(
&PlayerInfo::currentPlayingTrackChanged,
this,
&SetlogFeature::slotPlayingTrackChanged);
m_libraryWidget = libraryWidget;
m_libraryWidget = QPointer(libraryWidget);
}

void SetlogFeature::onRightClick(const QPoint& globalPos) {
Expand Down Expand Up @@ -397,17 +396,23 @@ void SetlogFeature::slotPlayingTrackChanged(TrackPointer currentPlayingTrack) {
if (m_pPlaylistTableModel->getPlaylist() == m_playlistId) {
// View needs a refresh

WTrackTableView* view = dynamic_cast<WTrackTableView*>(
m_libraryWidget->getActiveView());
if (view != nullptr) {
// We have a active view on the history. The user may have some
// important active selection. For example putting track into crates
// while the song changes trough autodj. The selection is then lost
// and dataloss occurs
const QList<TrackId> trackIds = view->getSelectedTrackIds();
m_pPlaylistTableModel->appendTrack(currentPlayingTrackId);
view->setSelectedTracks(trackIds);
} else {
bool hasActiveView = false;
if (m_libraryWidget) {
WTrackTableView* view = dynamic_cast<WTrackTableView*>(
uklotzde marked this conversation as resolved.
Show resolved Hide resolved
m_libraryWidget->getActiveView());
if (view != nullptr) {
// We have a active view on the history. The user may have some
// important active selection. For example putting track into crates
// while the song changes trough autodj. The selection is then lost
// and dataloss occurs
hasActiveView = true;
const QList<TrackId> trackIds = view->getSelectedTrackIds();
m_pPlaylistTableModel->appendTrack(currentPlayingTrackId);
view->setSelectedTracks(trackIds);
}
}

if (!hasActiveView) {
m_pPlaylistTableModel->appendTrack(currentPlayingTrackId);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/library/trackset/setlogfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ class SetlogFeature : public BasePlaylistFeature {
QAction* m_pJoinWithPreviousAction;
QAction* m_pStartNewPlaylist;
int m_playlistId;
WLibrary* m_libraryWidget;
QPointer<WLibrary> m_libraryWidget;
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
const QIcon m_icon;
};