From bd2fb552b50b589dc14191ee51e71fa80a86809b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 16 Apr 2021 11:20:04 +0200 Subject: [PATCH] [netinstall] let queue finish properly - if the queue is emptied, there was no usable data; set failure to NoData rather than BadData. - FetchNextUnless::done() is done only if the parameter is true (that is, it's done!); otherwise should continue. --- src/modules/netinstall/LoaderQueue.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/netinstall/LoaderQueue.cpp b/src/modules/netinstall/LoaderQueue.cpp index 76307d380..0644514c3 100644 --- a/src/modules/netinstall/LoaderQueue.cpp +++ b/src/modules/netinstall/LoaderQueue.cpp @@ -26,8 +26,9 @@ * the queue continues loading. Calling release() before the * destructor skips the fetchNext(), ending the queue-loading. * - * Calling done(b) is the same as release(), **plus** done() - * is called on the queue if @p b is @c true. + * Calling done(b) is a conditional release: if @p b is @c true, + * queues a call to done() on the queue and releases it; otherwise, + * does nothing. */ class FetchNextUnless { @@ -46,11 +47,14 @@ public: void release() { m_q = nullptr; } void done( bool b ) { - if ( b && m_q ) + if ( b ) { - QMetaObject::invokeMethod( m_q, "done", Qt::QueuedConnection ); + if ( m_q ) + { + QMetaObject::invokeMethod( m_q, "done", Qt::QueuedConnection ); + } + release(); } - release(); } private: @@ -94,7 +98,7 @@ LoaderQueue::fetchNext() { if ( m_queue.isEmpty() ) { - m_config->setStatus( Config::Status::FailedBadData ); + m_config->setStatus( Config::Status::FailedNoData ); emit done(); return; }