mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix extra qpainter end() call
This commit is contained in:
parent
705c174271
commit
5082280c0e
@ -371,36 +371,33 @@ class ImageView(QWidget, ImageDropMixin):
|
|||||||
pmap = self._pixmap
|
pmap = self._pixmap
|
||||||
p = QPainter(self)
|
p = QPainter(self)
|
||||||
p.setRenderHints(QPainter.RenderHint.Antialiasing | QPainter.RenderHint.SmoothPixmapTransform)
|
p.setRenderHints(QPainter.RenderHint.Antialiasing | QPainter.RenderHint.SmoothPixmapTransform)
|
||||||
try:
|
if pmap.isNull():
|
||||||
if pmap.isNull():
|
if self.draw_empty_border:
|
||||||
if self.draw_empty_border:
|
|
||||||
pen = QPen()
|
|
||||||
pen.setWidth(self.BORDER_WIDTH)
|
|
||||||
p.setPen(pen)
|
|
||||||
p.drawRect(self.rect())
|
|
||||||
p.end()
|
|
||||||
return
|
|
||||||
w, h = pmap.width(), pmap.height()
|
|
||||||
ow, oh = w, h
|
|
||||||
cw, ch = self.rect().width(), self.rect().height()
|
|
||||||
scaled, nw, nh = fit_image(w, h, cw, ch)
|
|
||||||
if scaled:
|
|
||||||
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.AspectRatioMode.IgnoreAspectRatio,
|
|
||||||
Qt.TransformationMode.SmoothTransformation)
|
|
||||||
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
|
|
||||||
x = int(abs(cw - w)/2)
|
|
||||||
y = int(abs(ch - h)/2)
|
|
||||||
target = QRect(x, y, w, h)
|
|
||||||
p.drawPixmap(target, pmap)
|
|
||||||
if self.draw_border:
|
|
||||||
pen = QPen()
|
pen = QPen()
|
||||||
pen.setWidth(self.BORDER_WIDTH)
|
pen.setWidth(self.BORDER_WIDTH)
|
||||||
p.setPen(pen)
|
p.setPen(pen)
|
||||||
p.drawRect(target)
|
p.drawRect(self.rect())
|
||||||
if self.show_size:
|
p.end()
|
||||||
draw_size(p, target, ow, oh)
|
return
|
||||||
finally:
|
w, h = pmap.width(), pmap.height()
|
||||||
p.end()
|
ow, oh = w, h
|
||||||
|
cw, ch = self.rect().width(), self.rect().height()
|
||||||
|
scaled, nw, nh = fit_image(w, h, cw, ch)
|
||||||
|
if scaled:
|
||||||
|
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.AspectRatioMode.IgnoreAspectRatio,
|
||||||
|
Qt.TransformationMode.SmoothTransformation)
|
||||||
|
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
|
||||||
|
x = int(abs(cw - w)/2)
|
||||||
|
y = int(abs(ch - h)/2)
|
||||||
|
target = QRect(x, y, w, h)
|
||||||
|
p.drawPixmap(target, pmap)
|
||||||
|
if self.draw_border:
|
||||||
|
pen = QPen()
|
||||||
|
pen.setWidth(self.BORDER_WIDTH)
|
||||||
|
p.setPen(pen)
|
||||||
|
p.drawRect(target)
|
||||||
|
if self.show_size:
|
||||||
|
draw_size(p, target, ow, oh)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user