mirror of
https://github.com/dguglielmi/sunny-overlay.git
synced 2025-12-06 13:52:40 +01:00
39 lines
1.4 KiB
Diff
39 lines
1.4 KiB
Diff
From 770220835757f677990c31f4bd95861ca8ef5853 Mon Sep 17 00:00:00 2001
|
|
From: Uwe Klotz <uklotz@mixxx.org>
|
|
Date: Thu, 26 Apr 2018 14:43:32 +0200
|
|
Subject: [PATCH] Fix memory leak when loading cover art
|
|
|
|
---
|
|
src/library/coverartcache.cpp | 11 ++++++++---
|
|
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/library/coverartcache.cpp b/src/library/coverartcache.cpp
|
|
index eb91411473..e76168422d 100644
|
|
--- a/src/library/coverartcache.cpp
|
|
+++ b/src/library/coverartcache.cpp
|
|
@@ -94,6 +94,7 @@ QPixmap CoverArtCache::requestCover(const CoverInfo& requestInfo,
|
|
}
|
|
|
|
m_runningRequests.insert(requestId);
|
|
+ // The watcher will be deleted in coverLoaded()
|
|
QFutureWatcher<FutureResult>* watcher = new QFutureWatcher<FutureResult>(this);
|
|
QFuture<FutureResult> future = QtConcurrent::run(
|
|
this, &CoverArtCache::loadCover, requestInfo, pRequestor,
|
|
@@ -146,9 +147,13 @@ CoverArtCache::FutureResult CoverArtCache::loadCover(
|
|
|
|
// watcher
|
|
void CoverArtCache::coverLoaded() {
|
|
- QFutureWatcher<FutureResult>* watcher;
|
|
- watcher = reinterpret_cast<QFutureWatcher<FutureResult>*>(sender());
|
|
- FutureResult res = watcher->result();
|
|
+ FutureResult res;
|
|
+ {
|
|
+ QFutureWatcher<FutureResult>* watcher =
|
|
+ static_cast<QFutureWatcher<FutureResult>*>(sender());
|
|
+ res = watcher->result();
|
|
+ watcher->deleteLater();
|
|
+ }
|
|
|
|
if (sDebug) {
|
|
kLogger.debug() << "coverLoaded" << res.cover;
|