@@ -13,12 +13,12 @@ DisplayWidget::DisplayWidget(QSharedPointer<DisplayInterface> display,
13
13
QWidget(parent),
14
14
m_display(display),
15
15
m_handle(handle),
16
- m_redrawing (false )
16
+ m_repaintScheduled (false )
17
17
{
18
18
this ->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
19
19
this ->setMouseTracking (true );
20
20
21
- connect (m_handle.data (), SIGNAL (containerChanged ()), this , SLOT (checkFullRedraw ()));
21
+ connect (m_handle.data (), SIGNAL (containerChanged ()), this , SLOT (checkFullRedraw ()), Qt::QueuedConnection );
22
22
connect (m_handle.data (), SIGNAL (currentContainerChanged ()), this , SLOT (checkNewContainer ()));
23
23
24
24
connect (m_handle.data (), SIGNAL (overlayRedrawRequested (DisplayInterface*)), this , SLOT (checkOverlayRedraw (DisplayInterface*)));
@@ -84,6 +84,8 @@ void DisplayWidget::paintEvent(QPaintEvent *event)
84
84
if (!overlay.isNull ()) {
85
85
painter.drawImage (0 , 0 , overlay);
86
86
}
87
+
88
+ m_repaintScheduled = false ;
87
89
}
88
90
89
91
void DisplayWidget::wheelEvent (QWheelEvent *event)
@@ -152,7 +154,7 @@ void DisplayWidget::performDisplayRender()
152
154
this ->size (),
153
155
m_displayParameters,
154
156
m_displayRenderProgress);
155
- connect (&m_displayRenderWatcher, &QFutureWatcher<QImage>::finished, [this ]() {
157
+ connect (&m_displayRenderWatcher, &QFutureWatcher<QImage>::finished, this , [this ]() {
156
158
if (this ->m_displayRenderWatcher .isFinished ()) {
157
159
this ->setDisplayImage (this ->m_displayRenderWatcher .result ());
158
160
}
@@ -175,8 +177,9 @@ void DisplayWidget::handleDisplayRenderPreview(QString type, QVariant value)
175
177
176
178
void DisplayWidget::setDisplayImage (QImage image)
177
179
{
180
+ QMutexLocker lock (&m_mutex);
178
181
m_displayImage = image;
179
- update ();
182
+ scheduleRepaint ();
180
183
}
181
184
182
185
void DisplayWidget::resetRendering ()
@@ -193,15 +196,8 @@ void DisplayWidget::resetRendering()
193
196
194
197
void DisplayWidget::fullRedraw ()
195
198
{
196
- if (m_redrawing) {
197
- return ;
198
- }
199
- m_redrawing = true ;
200
- disconnect (m_handle.data (), SIGNAL (containerChanged ()), this , SLOT (checkFullRedraw ()));
201
199
performDisplayRender ();
202
- update ();
203
- connect (m_handle.data (), SIGNAL (containerChanged ()), this , SLOT (checkFullRedraw ()));
204
- m_redrawing = false ;
200
+ scheduleRepaint ();
205
201
}
206
202
207
203
void DisplayWidget::showContextMenu (const QPoint &point)
@@ -443,6 +439,7 @@ void DisplayWidget::checkNewContainer()
443
439
444
440
void DisplayWidget::checkFullRedraw (DisplayInterface *display)
445
441
{
442
+ QMutexLocker lock (&m_mutex);
446
443
if (!m_handle->activeDisplays ().contains (this )) {
447
444
return ;
448
445
}
@@ -454,12 +451,22 @@ void DisplayWidget::checkFullRedraw(DisplayInterface *display)
454
451
455
452
void DisplayWidget::checkOverlayRedraw (DisplayInterface *display)
456
453
{
454
+ QMutexLocker lock (&m_mutex);
457
455
if (!m_handle->activeDisplays ().contains (this )) {
458
456
return ;
459
457
}
460
458
if (display != nullptr && display != m_display.data ()) {
461
459
return ;
462
460
}
461
+ scheduleRepaint ();
462
+ }
463
+
464
+ void DisplayWidget::scheduleRepaint ()
465
+ {
466
+ if (m_repaintScheduled) {
467
+ return ;
468
+ }
469
+ m_repaintScheduled = true ;
463
470
update ();
464
471
}
465
472
0 commit comments