diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 123a87e66..37016d420 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1386,11 +1386,16 @@ private: } public: + bool hasQueueItems() const + { + return _tileQueue && !_tileQueue->isEmpty(); + } + void drainQueue(const std::chrono::steady_clock::time_point &/*now*/) { try { - while (!_tileQueue->isEmpty()) + while (hasQueueItems()) { if (_stop || SigUtil::getTerminationFlag()) { @@ -1679,7 +1684,10 @@ public: _pollEnd = std::chrono::steady_clock::now() + std::chrono::microseconds(timeoutMicroS); do { - if (poll(timeoutMicroS) <= 0) + int realTimeout = timeoutMicroS; + if (_document && _document->hasQueueItems()) + realTimeout = 0; + if (poll(realTimeout) <= 0) break; const auto now = std::chrono::steady_clock::now();