mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Don't crash when adding new columns to a stretch header view.
Fixes issue 2562
This commit is contained in:
parent
11619c9484
commit
bfd725f2ed
@ -89,6 +89,7 @@ PlaylistView::PlaylistView(QWidget *parent)
|
||||
setting_initial_header_layout_(false),
|
||||
upgrading_from_qheaderview_(false),
|
||||
read_only_settings_(true),
|
||||
upgrading_from_version_(-1),
|
||||
glow_enabled_(true),
|
||||
currently_glowing_(false),
|
||||
glow_intensity_step_(0),
|
||||
@ -255,6 +256,8 @@ void PlaylistView::LoadGeometry() {
|
||||
// New columns that we add are visible by default if the user has upgraded
|
||||
// Clementine. Hide them again here
|
||||
const int state_version = settings.value("state_version", 0).toInt();
|
||||
upgrading_from_version_ = state_version;
|
||||
|
||||
if (state_version < 1) {
|
||||
header_->HideSection(Playlist::Column_Rating);
|
||||
header_->HideSection(Playlist::Column_PlayCount);
|
||||
@ -267,9 +270,6 @@ void PlaylistView::LoadGeometry() {
|
||||
if (state_version < 3) {
|
||||
header_->HideSection(Playlist::Column_Comment);
|
||||
}
|
||||
if (state_version < 4) {
|
||||
header_->SetColumnWidth(Playlist::Column_Source, 0.05);
|
||||
}
|
||||
|
||||
// Make sure at least one column is visible
|
||||
bool all_hidden = true;
|
||||
@ -897,6 +897,13 @@ void PlaylistView::ReloadSettings() {
|
||||
header_->SetColumnWidth(Playlist::Column_Track, 0.05);
|
||||
setting_initial_header_layout_ = false;
|
||||
}
|
||||
|
||||
if (upgrading_from_version_ != -1) {
|
||||
if (upgrading_from_version_ < 4) {
|
||||
header_->SetColumnWidth(Playlist::Column_Source, 0.05);
|
||||
}
|
||||
upgrading_from_version_ = -1;
|
||||
}
|
||||
|
||||
column_alignment_ = s.value("column_alignments").value<ColumnAlignmentMap>();
|
||||
if (column_alignment_.isEmpty()) {
|
||||
|
@ -168,6 +168,7 @@ class PlaylistView : public QTreeView {
|
||||
bool setting_initial_header_layout_;
|
||||
bool upgrading_from_qheaderview_;
|
||||
bool read_only_settings_;
|
||||
int upgrading_from_version_;
|
||||
|
||||
bool background_enabled_;
|
||||
|
||||
|
@ -270,6 +270,11 @@ bool StretchHeaderView::RestoreState(const QByteArray& data) {
|
||||
resizeSection(i, pixel_widths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Have we added more columns since the last time?
|
||||
while (column_widths_.count() < count()) {
|
||||
column_widths_ << 0;
|
||||
}
|
||||
|
||||
if (stretch_enabled_) {
|
||||
// In stretch mode, we've already set the proportional column widths so apply
|
||||
|
Loading…
Reference in New Issue
Block a user