diff options
-rw-r--r-- | common/store.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/common/store.cpp b/common/store.cpp index 0328c7f..b68cb68 100644 --- a/common/store.cpp +++ b/common/store.cpp | |||
@@ -312,8 +312,11 @@ KAsync::Job<void> Store::removeDataFromDisk(const QByteArray &identifier) | |||
312 | .then<void>([resourceAccess](KAsync::Future<void> &future) { | 312 | .then<void>([resourceAccess](KAsync::Future<void> &future) { |
313 | if (resourceAccess->isReady()) { | 313 | if (resourceAccess->isReady()) { |
314 | //Wait for the resource shutdown | 314 | //Wait for the resource shutdown |
315 | QObject::connect(resourceAccess.data(), &ResourceAccess::ready, [&future](bool ready) { | 315 | auto guard = new QObject; |
316 | QObject::connect(resourceAccess.data(), &ResourceAccess::ready, guard, [&future, guard](bool ready) { | ||
316 | if (!ready) { | 317 | if (!ready) { |
318 | //We don't disconnect if ResourceAccess get's recycled, so ready can fire multiple times, which can result in a crash if the future is no longer valid. | ||
319 | delete guard; | ||
317 | future.setFinished(); | 320 | future.setFinished(); |
318 | } | 321 | } |
319 | }); | 322 | }); |