OnroadAlerts: construct QPainter only when needed (#21260)

This commit is contained in:
Dean Lee
2021-06-14 23:42:59 +08:00
committed by GitHub
parent 715dbd4882
commit d07b45f50a
+2 -2
View File
@@ -148,8 +148,6 @@ void OnroadAlerts::stopSounds() {
}
void OnroadAlerts::paintEvent(QPaintEvent *event) {
QPainter p(this);
if (alert_size == cereal::ControlsState::AlertSize::NONE) {
return;
}
@@ -161,6 +159,8 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
int h = alert_sizes[alert_size];
QRect r = QRect(0, height() - h, width(), h);
QPainter p(this);
// draw background + gradient
p.setPen(Qt::NoPen);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);