[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.
This commit is contained in:
Adriaan de Groot 2021-04-16 11:20:04 +02:00
parent 67effe4214
commit bd2fb552b5

View File

@ -26,8 +26,9 @@
* the queue continues loading. Calling release() before the * the queue continues loading. Calling release() before the
* destructor skips the fetchNext(), ending the queue-loading. * destructor skips the fetchNext(), ending the queue-loading.
* *
* Calling done(b) is the same as release(), **plus** done() * Calling done(b) is a conditional release: if @p b is @c true,
* is called on the queue if @p b is @c true. * queues a call to done() on the queue and releases it; otherwise,
* does nothing.
*/ */
class FetchNextUnless class FetchNextUnless
{ {
@ -46,11 +47,14 @@ public:
void release() { m_q = nullptr; } void release() { m_q = nullptr; }
void done( bool b ) 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: private:
@ -94,7 +98,7 @@ LoaderQueue::fetchNext()
{ {
if ( m_queue.isEmpty() ) if ( m_queue.isEmpty() )
{ {
m_config->setStatus( Config::Status::FailedBadData ); m_config->setStatus( Config::Status::FailedNoData );
emit done(); emit done();
return; return;
} }