From 8a78dbe0612fda7cd66b43057f6d467d3e1844dd Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 7 Oct 2016 15:41:56 +0200 Subject: A resource shutdown is only complete once we receive the notification. Otherwise the tests might try to start a new resource before the last one even shut down. --- common/resourcecontrol.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'common/resourcecontrol.cpp') diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp index f509318..90c8fb9 100644 --- a/common/resourcecontrol.cpp +++ b/common/resourcecontrol.cpp @@ -53,8 +53,18 @@ KAsync::Job ResourceControl::shutdown(const QByteArray &identifier) resourceAccess->open(); return resourceAccess->sendCommand(Sink::Commands::ShutdownCommand) .addToContext(resourceAccess) - .syncThen([resourceAccess, time]() { - resourceAccess->close(); + .then([resourceAccess, time](KAsync::Future &future) { + SinkTrace() << "Shutdown command complete, waiting for shutdown." << Log::TraceTime(time->elapsed()); + if (!resourceAccess->isReady()) { + future.setFinished(); + return; + } + QObject::connect(resourceAccess.data(), &ResourceAccess::ready, [&future](bool ready) { + if (!ready) { + future.setFinished(); + } + }); + }).syncThen([time] { SinkTrace() << "Shutdown complete." << Log::TraceTime(time->elapsed()); }); }); -- cgit v1.2.3