Skip to content

Commit

Permalink
PlaylistView: Ignore invalid QHeaderView::sectionResized
Browse files Browse the repository at this point in the history
Workaround a possible Qt bug: moving a song in the playlist triggers `QHeaderView::sectionResized` with the state reset for each column, this causes an an invalid state for the last column since SetHeaderState is called before the last column state is restored, which again is used when restoring the playlist columns after switching to different playlist. To workaround this, only call SetHeaderState when the new column size is not zero.
  • Loading branch information
jonaski committed Nov 23, 2024
1 parent 8f7e29f commit 9bff55e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/playlist/playlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ PlaylistView::PlaylistView(QWidget *parent)
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
#endif

QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::SetHeaderState);
QObject::connect(header_, &PlaylistHeader::sectionResized, this, &PlaylistView::HeaderSectionResized);
QObject::connect(header_, &PlaylistHeader::sectionMoved, this, &PlaylistView::SetHeaderState);
QObject::connect(header_, &PlaylistHeader::sortIndicatorChanged, this, &PlaylistView::SetHeaderState);
QObject::connect(header_, &PlaylistHeader::SectionVisibilityChanged, this, &PlaylistView::SetHeaderState);
Expand Down Expand Up @@ -423,6 +423,17 @@ void PlaylistView::RestoreHeaderState() {

}

void PlaylistView::HeaderSectionResized(const int logical_index, const int old_size, const int new_size) {

Q_UNUSED(logical_index)
Q_UNUSED(old_size)

if (new_size != 0) {
SetHeaderState();
}

}

void PlaylistView::ReloadBarPixmaps() {

currenttrack_bar_left_ = LoadBarPixmap(u":/pictures/currenttrack_bar_left.png"_s, true);
Expand Down
1 change: 1 addition & 0 deletions src/playlist/playlistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class PlaylistView : public QTreeView {
private Q_SLOTS:
void Update() { update(); }
void SetHeaderState();
void HeaderSectionResized(const int logical_index, const int old_size, const int new_size);
void InhibitAutoscrollTimeout();
void MaybeAutoscroll(const Playlist::AutoScroll autoscroll);
void InvalidateCachedCurrentPixmap();
Expand Down

0 comments on commit 9bff55e

Please sign in to comment.