mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
statistics: leak textures on exit
The scatter plot items shared their textures. These were std::unique_ptrs and cleaned up on exit. Owing to QSG's broken memory model, freeing the textures after QApplication terminated its threads led to crashes. Therefore, leak the textures. Not satisfying, but ultimately harmless and better than a crash. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9e61a6372a
commit
e32e6d63a7
1 changed files with 9 additions and 7 deletions
|
@ -117,7 +117,7 @@ ChartScatterItem::~ChartScatterItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<QSGTexture> createScatterTexture(StatsView &view, const QColor &color, const QColor &borderColor)
|
static QSGTexture *createScatterTexture(StatsView &view, const QColor &color, const QColor &borderColor)
|
||||||
{
|
{
|
||||||
QImage img(scatterItemDiameter, scatterItemDiameter, QImage::Format_ARGB32);
|
QImage img(scatterItemDiameter, scatterItemDiameter, QImage::Format_ARGB32);
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
|
@ -130,13 +130,15 @@ static std::unique_ptr<QSGTexture> createScatterTexture(StatsView &view, const Q
|
||||||
painter.drawEllipse(scatterItemBorder, scatterItemBorder,
|
painter.drawEllipse(scatterItemBorder, scatterItemBorder,
|
||||||
scatterItemDiameter - 2 * scatterItemBorder,
|
scatterItemDiameter - 2 * scatterItemBorder,
|
||||||
scatterItemDiameter - 2 * scatterItemBorder);
|
scatterItemDiameter - 2 * scatterItemBorder);
|
||||||
return std::unique_ptr<QSGTexture>(
|
return view.w()->createTextureFromImage(img, QQuickWindow::TextureHasAlphaChannel);
|
||||||
view.w()->createTextureFromImage(img, QQuickWindow::TextureHasAlphaChannel)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<QSGTexture> scatterItemTexture;
|
// Note: Originally these were std::unique_ptrs, which automatically
|
||||||
std::unique_ptr<QSGTexture> scatterItemHighlightedTexture;
|
// freed the textures on exit. However, destroying textures after
|
||||||
|
// QApplication finished its thread leads to crashes. Therefore, these
|
||||||
|
// are now normal pointers and the texture objects are leaked.
|
||||||
|
static QSGTexture *scatterItemTexture = nullptr;
|
||||||
|
static QSGTexture *scatterItemHighlightedTexture = nullptr;
|
||||||
|
|
||||||
void ChartScatterItem::render()
|
void ChartScatterItem::render()
|
||||||
{
|
{
|
||||||
|
@ -151,7 +153,7 @@ void ChartScatterItem::render()
|
||||||
}
|
}
|
||||||
updateVisible();
|
updateVisible();
|
||||||
if (textureDirty) {
|
if (textureDirty) {
|
||||||
node->node->setTexture(highlighted ? scatterItemHighlightedTexture.get() : scatterItemTexture.get());
|
node->node->setTexture(highlighted ? scatterItemHighlightedTexture : scatterItemTexture);
|
||||||
textureDirty = false;
|
textureDirty = false;
|
||||||
}
|
}
|
||||||
if (positionDirty) {
|
if (positionDirty) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue