PlaylistView: Ignore invalid QHeaderView::sectionResized
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.
This commit is contained in:
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user