Skip to content

Commit

Permalink
Break infinite update() loop in sidebar
Browse files Browse the repository at this point in the history
Resulted from misuse of the Qt APIs. Use them more as intended.

Closes #782.
  • Loading branch information
lmoureaux committed Dec 26, 2021
1 parent 4c2ecbf commit 7aa4d96
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions client/gui-qt/diplodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void diplo_wdg::restore_pixmap()
queen()->sw_diplo->resizePixmap(queen()->sw_diplo->width(),
queen()->sw_diplo->height());
queen()->sw_diplo->setCustomLabels(QString());
queen()->sw_diplo->updateFinalPixmap();
queen()->sw_diplo->update();
}

/**
Expand Down Expand Up @@ -893,7 +893,7 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
queen()->sw_diplo->height());
queen()->sw_diplo->setCustomLabels(
QString(nation_plural_for_player(player_by_number(counterpart))));
queen()->sw_diplo->updateFinalPixmap();
queen()->sw_diplo->update();
delete pix2;
if (!queen()->isRepoDlgOpen(QStringLiteral("DDI"))) {
dd = new diplo_dlg(counterpart, initiated_from);
Expand Down
2 changes: 1 addition & 1 deletion client/gui-qt/mapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void update_mouse_cursor(enum cursor_type new_cursor_type)
void qtg_update_timeout_label()
{
queen()->sw_endturn->setCustomLabels(QString(get_timeout_label_text()));
queen()->sw_endturn->updateFinalPixmap();
queen()->sw_endturn->update();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions client/gui-qt/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void pageGame::updateInfoLabelTimeout()
.arg(calendar_text(), QString::number(game.info.turn));

sw_map->setCustomLabels(s);
sw_map->updateFinalPixmap();
sw_map->update();

if (client.conn.playing != NULL) {
if (player_get_expected_income(client.conn.playing) > 0) {
Expand All @@ -256,9 +256,9 @@ void pageGame::updateInfoLabelTimeout()
} else {
sw_economy->setCustomLabels(QLatin1String(""));
}
sw_indicators->updateFinalPixmap();
sw_tax->updateFinalPixmap();
sw_economy->updateFinalPixmap();
sw_indicators->update();
sw_tax->update();
sw_economy->update();
FC_FREE(update_info_timer);
}

Expand Down Expand Up @@ -552,7 +552,7 @@ void fc_game_tab_widget::current_changed(int index)
}

for (auto *sw : qAsConst(queen()->sidebar_wdg->objects)) {
sw->updateFinalPixmap();
sw->update();
}
currentWidget()->hide();
widget(index)->show();
Expand Down
2 changes: 1 addition & 1 deletion client/gui-qt/sciencedlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void real_science_report_dialog_update(void *unused)
} else {
queen()->sw_science->keep_blinking = false;
queen()->sw_science->setCustomLabels(str);
queen()->sw_science->updateFinalPixmap();
queen()->sw_science->update();
}
queen()->updateSidebarTooltips();

Expand Down
10 changes: 3 additions & 7 deletions client/gui-qt/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ void sidebarWidget::enterEvent(QEvent *event)
{
if (!hover) {
hover = true;
updateFinalPixmap();
QWidget::enterEvent(event);
update();
}
Expand All @@ -202,7 +201,6 @@ void sidebarWidget::leaveEvent(QEvent *event)
{
if (hover) {
hover = false;
updateFinalPixmap();
QWidget::leaveEvent(event);
update();
}
Expand All @@ -215,7 +213,6 @@ void sidebarWidget::contextMenuEvent(QContextMenuEvent *event)
{
if (hover) {
hover = false;
updateFinalPixmap();
QWidget::contextMenuEvent(event);
update();
}
Expand Down Expand Up @@ -287,7 +284,7 @@ void sidebarWidget::sblink()
timer->stop();
}
}
updateFinalPixmap();
update();
}

/**
Expand Down Expand Up @@ -457,7 +454,6 @@ void sidebarWidget::updateFinalPixmap()
}

p.end();
update();
}

/**
Expand Down Expand Up @@ -579,7 +575,7 @@ void sidebarDisableEndturn(bool do_restore)
return;
}
queen()->sw_endturn->disabled = !do_restore;
queen()->sw_endturn->updateFinalPixmap();
queen()->sw_endturn->update();
}

/**
Expand All @@ -591,7 +587,7 @@ void sidebarBlinkEndturn(bool do_restore)
return;
}
queen()->sw_endturn->blink = !do_restore;
queen()->sw_endturn->updateFinalPixmap();
queen()->sw_endturn->update();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion client/gui-qt/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class sidebarWidget : public QWidget {
void setTooltip(const QString &tooltip);
void setWheelDown(pfcn func);
void setWheelUp(pfcn func);
void updateFinalPixmap();

bool blink;
bool keep_blinking;
Expand All @@ -75,6 +74,7 @@ public slots:
void wheelEvent(QWheelEvent *event) override;

private:
void updateFinalPixmap();
void paint();
bool hover;
pfcn right_click;
Expand Down

0 comments on commit 7aa4d96

Please sign in to comment.