Skip to content

Commit

Permalink
Narrow the QPixmapPainter scope, to not alter/redraw the pixmap with …
Browse files Browse the repository at this point in the history
…when a painter is still not descructed.
  • Loading branch information
daschuer committed Sep 22, 2024
1 parent c3167df commit 02137d8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/widget/paintable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ void Paintable::drawInternal(const QRectF& targetRect, QPainter* pPainter,
m_pPixmap = std::make_unique<QPixmap>(m_pSvg->defaultSize());
m_pPixmap->setDevicePixelRatio(devicePixelRatio);
m_pPixmap->fill(Qt::transparent);
auto pixmapPainter = QPainter(m_pPixmap.get());
m_pSvg->render(&pixmapPainter);
{ // QPainter Scope
auto pixmapPainter = QPainter(m_pPixmap.get());
m_pSvg->render(&pixmapPainter);
}
mayCorrectColors();
}
// The SVG renderer doesn't directly support tiling, so we render
Expand All @@ -253,9 +255,11 @@ void Paintable::drawInternal(const QRectF& targetRect, QPainter* pPainter,
m_pPixmap = std::make_unique<QPixmap>(targetRect.size().toSize());
m_pPixmap->setDevicePixelRatio(devicePixelRatio);
m_pPixmap->fill(Qt::transparent);
auto pixmapPainter = QPainter(m_pPixmap.get());
m_pSvg->setViewBox(sourceRect);
m_pSvg->render(&pixmapPainter);
{ // QPainter Scope
auto pixmapPainter = QPainter(m_pPixmap.get());
m_pSvg->setViewBox(sourceRect);
m_pSvg->render(&pixmapPainter);
}
mayCorrectColors();
m_lastSourceRect = sourceRect;
}
Expand Down

0 comments on commit 02137d8

Please sign in to comment.