diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-19 09:01:14 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2021-01-20 08:47:18 +0100 |
commit | e32e6d63a7c158a03a851492f4f9d3edffe2f857 (patch) | |
tree | 99942fc7e0f6fbe8c9f02f43e3942cad99b35b11 /stats | |
parent | 9e61a6372a0709a6ddaef5749a27b05d84c5f70c (diff) | |
download | subsurface-e32e6d63a7c158a03a851492f4f9d3edffe2f857.tar.gz |
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>
Diffstat (limited to 'stats')
-rw-r--r-- | stats/chartitem.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/stats/chartitem.cpp b/stats/chartitem.cpp index 6a69b6973..7c5339596 100644 --- a/stats/chartitem.cpp +++ b/stats/chartitem.cpp @@ -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); img.fill(Qt::transparent); @@ -130,13 +130,15 @@ static std::unique_ptr<QSGTexture> createScatterTexture(StatsView &view, const Q painter.drawEllipse(scatterItemBorder, scatterItemBorder, scatterItemDiameter - 2 * scatterItemBorder, scatterItemDiameter - 2 * scatterItemBorder); - return std::unique_ptr<QSGTexture>( - view.w()->createTextureFromImage(img, QQuickWindow::TextureHasAlphaChannel) - ); + return view.w()->createTextureFromImage(img, QQuickWindow::TextureHasAlphaChannel); } -std::unique_ptr<QSGTexture> scatterItemTexture; -std::unique_ptr<QSGTexture> scatterItemHighlightedTexture; +// Note: Originally these were std::unique_ptrs, which automatically +// 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() { @@ -151,7 +153,7 @@ void ChartScatterItem::render() } updateVisible(); if (textureDirty) { - node->node->setTexture(highlighted ? scatterItemHighlightedTexture.get() : scatterItemTexture.get()); + node->node->setTexture(highlighted ? scatterItemHighlightedTexture : scatterItemTexture); textureDirty = false; } if (positionDirty) { |