Skip to content

Commit 3bb1457

Browse files
authored
Merge pull request #8835 from The-OpenROAD-Project-staging/gui-timer
gui: reuse the same single shot timer for fullRepaint
2 parents 8fbfca3 + df9dc79 commit 3bb1457

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/gui/src/layoutViewer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,32 +141,34 @@ LayoutViewer::LayoutViewer(
141141
focus_nets_(focus_nets),
142142
route_guides_(route_guides),
143143
net_tracks_(net_tracks),
144-
viewer_thread_(this),
145-
loading_timer_(new QTimer(this))
144+
viewer_thread_(this)
146145
{
147146
setMouseTracking(true);
148147

149148
addMenuAndActions();
150149

151-
loading_timer_->setInterval(300 /*ms*/);
150+
loading_timer_.setInterval(300 /*ms*/);
152151

153152
connect(
154153
&viewer_thread_, &RenderThread::done, this, &LayoutViewer::updatePixmap);
155154

156-
connect(loading_timer_,
155+
connect(&loading_timer_,
157156
&QTimer::timeout,
158157
this,
159158
&LayoutViewer::handleLoadingIndication);
160159

161160
connect(&search_, &Search::modified, this, &LayoutViewer::fullRepaint);
162161

163162
connect(&search_, &Search::newChip, this, &LayoutViewer::setChip);
163+
164+
repaint_timer_.setSingleShot(true);
165+
repaint_timer_.callOnTimeout(this, &LayoutViewer::fullRepaint);
164166
}
165167

166168
void LayoutViewer::handleLoadingIndication()
167169
{
168170
if (!viewer_thread_.isRendering()) {
169-
loading_timer_->stop();
171+
loading_timer_.stop();
170172
return;
171173
}
172174

@@ -176,7 +178,7 @@ void LayoutViewer::handleLoadingIndication()
176178
void LayoutViewer::setLoadingState()
177179
{
178180
loading_indicator_.clear();
179-
loading_timer_->start();
181+
loading_timer_.start();
180182
}
181183

182184
void LayoutViewer::setChip(odb::dbChip* chip)
@@ -1933,8 +1935,7 @@ void LayoutViewer::paintEvent(QPaintEvent* event)
19331935
void LayoutViewer::fullRepaint()
19341936
{
19351937
if (command_executing_ && !paused_) {
1936-
QTimer::singleShot(
1937-
5 /*ms*/, this, &LayoutViewer::fullRepaint); // retry later
1938+
repaint_timer_.start(5 /* ms */);
19381939
return;
19391940
}
19401941

src/gui/src/layoutViewer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ class LayoutViewer : public QWidget
429429
RenderThread viewer_thread_;
430430
QPixmap draw_pixmap_;
431431
QRect draw_pixmap_bounds_;
432-
QTimer* loading_timer_;
432+
QTimer loading_timer_;
433+
QTimer repaint_timer_;
433434
std::string loading_indicator_;
434435

435436
static constexpr qreal kZoomScaleFactor = 1.2;

0 commit comments

Comments
 (0)