From 3c398bd15eca0dc33e6f8a29365ea0dc10f3b12e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Apr 2021 16:45:01 +0200 Subject: [PATCH] [netinstall] Only wrap-up if the packages list is OK Avoid situation where the YAML is ok but doesn't contain a list of netinstall packages, so the packages list (the model) is still empty. FIXES #1673 --- src/modules/netinstall/Config.h | 4 +++- src/modules/netinstall/LoaderQueue.cpp | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/modules/netinstall/Config.h b/src/modules/netinstall/Config.h index b676a7d39..58931c636 100644 --- a/src/modules/netinstall/Config.h +++ b/src/modules/netinstall/Config.h @@ -49,10 +49,12 @@ public: FailedNetworkError, FailedBadData, FailedNoData - }; + /// Human-readable, translated representation of the status QString status() const; + /// Internal code for the status + Status statusCode() const { return m_status; } void setStatus( Status s ); bool required() const { return m_required; } diff --git a/src/modules/netinstall/LoaderQueue.cpp b/src/modules/netinstall/LoaderQueue.cpp index f8ba17cff..76307d380 100644 --- a/src/modules/netinstall/LoaderQueue.cpp +++ b/src/modules/netinstall/LoaderQueue.cpp @@ -25,6 +25,9 @@ * On destruction, a new call to fetchNext() is queued, so that * 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. */ class FetchNextUnless { @@ -41,6 +44,14 @@ public: } } void release() { m_q = nullptr; } + void done( bool b ) + { + if ( b && m_q ) + { + QMetaObject::invokeMethod( m_q, "done", Qt::QueuedConnection ); + } + release(); + } private: LoaderQueue* m_q = nullptr; @@ -138,7 +149,7 @@ LoaderQueue::fetch( const QUrl& url ) void LoaderQueue::dataArrived() { - FetchNextUnless finished( this ); + FetchNextUnless next( this ); if ( !m_reply || !m_reply->isFinished() ) { @@ -170,16 +181,14 @@ LoaderQueue::dataArrived() if ( groups.IsSequence() ) { - finished.release(); m_config->loadGroupList( CalamaresUtils::yamlSequenceToVariant( groups ) ); - emit done(); + next.done( m_config->statusCode() == Config::Status::Ok ); } else if ( groups.IsMap() ) { - finished.release(); auto map = CalamaresUtils::yamlMapToVariant( groups ); m_config->loadGroupList( map.value( "groups" ).toList() ); - emit done(); + next.done( m_config->statusCode() == Config::Status::Ok ); } else {