From d78d263996aa737571b853dade0475e929d0ca48 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 6 Aug 2017 10:10:04 -0400 Subject: [PATCH] try to fix flickering live preview during export by temporarily asking Qt not to clear the widget's paint region --- src/mainwindow.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mainwindow.py b/src/mainwindow.py index 1c8806d..825b5bc 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -31,6 +31,7 @@ class PreviewWindow(QtWidgets.QLabel): self.parent = parent self.setFrameStyle(QtWidgets.QFrame.StyledPanel) self.pixmap = QtGui.QPixmap(img) + self.isFlickering = 0 def paintEvent(self, event): size = self.size() @@ -47,9 +48,23 @@ class PreviewWindow(QtWidgets.QLabel): painter.drawPixmap(point, scaledPix) def changePixmap(self, img): + if self.parent.encoding: + # track time to determine if the preview is flickering due to lag + bTime = time.time() + elif self.isFlickering > 0: + # no longer exporting video so reset the paint area to normal + self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False) + self.isFlickering = 0 + self.pixmap = QtGui.QPixmap(img) self.repaint() + if self.parent.encoding and time.time() - bTime > 1.1: + self.isFlickering += 1 + if self.isFlickering == 8: + # if export is lagging, temporarily disable clearing the paint area + self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, True) + @QtCore.pyqtSlot(str) def threadError(self, msg): self.parent.showMessage(