Skip to content

Commit

Permalink
Fix: Crash on qDebug, Fix: Incorrect column limit
Browse files Browse the repository at this point in the history
  • Loading branch information
rurigk committed Jul 18, 2020
1 parent 26362eb commit f804015
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions colorpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ ColorPanel::ColorPanel(QWidget *parent)
colorPickerHistory = new ColorPickerHistory();
colorPickerHistory->LoadHistory();

historyColumns = 7;

FillHistory();
FillToolbarHistory();

Expand Down Expand Up @@ -342,8 +340,8 @@ void ColorPanel::on_pickColorButton_clicked()

void ColorPanel::FillHistory()
{
historyColumns = ui->scrollAreaWidgetContentsHistory->width() / (32 + 6);
qDebug() << "Columns: " << historyColumns << " width: " << ui->scrollAreaWidgetContentsHistory->width();
//historyColumns = ui->scrollAreaWidgetContentsHistory->width() / (32 + 6);
//qDebug() << "Columns: " << historyColumns << " width: " << ui->scrollAreaWidgetContentsHistory->geometry().width();

QGridLayout * layout = new QGridLayout();

Expand Down Expand Up @@ -386,9 +384,9 @@ void ColorPanel::FillHistory()
}

QSpacerItem * spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addItem(spacer, row, historyColumns+1, 1, -1, Qt::AlignTop);
layout->addItem(spacer, row, historyColumns-1, 1, -1, Qt::AlignTop);

delete ui->scrollAreaWidgetContentsHistory->layout();
//delete ui->scrollAreaWidgetContentsHistory->layout();
qDeleteAll(ui->scrollAreaWidgetContentsHistory->children());

ui->scrollAreaWidgetContentsHistory->setLayout(layout);
Expand Down Expand Up @@ -518,9 +516,9 @@ void ColorPanel::on_clearHistoryButton_clicked()
switch (confirmationReturn) {
case QMessageBox::Ok:
colorPickerHistory->Clear();
colorPickerHistory->SaveHistory();
FillHistory();
FillToolbarHistory();
colorPickerHistory->SaveHistory();
break;
default:
// should never be reached
Expand Down
2 changes: 1 addition & 1 deletion colorpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private slots:
bool toolbarMode = true;
bool restoreAfterPick = false;

int historyColumns;
int historyColumns = 15;

void CreateTrayIcon();
void CreateTrayActions();
Expand Down

0 comments on commit f804015

Please sign in to comment.