[netinstall] Missing initialisations, split out slot

- m_queue was not initialized to nullptr, crashes
- split queue-is-done to a separate slot rather than a lambda
- prefer queueing calls to fetchNext(), for responsiveness
This commit is contained in:
Adriaan de Groot 2021-03-19 11:41:47 +01:00
parent 404a9ef98a
commit 03d086a233
3 changed files with 21 additions and 6 deletions

View File

@ -93,6 +93,17 @@ Config::loadGroupList( const QVariantList& groupData )
emit statusReady();
}
void
Config::loadingDone()
{
if ( m_queue )
{
m_queue->deleteLater();
m_queue = nullptr;
}
}
void
Config::setConfigurationMap( const QVariantMap& configurationMap )
{
@ -133,11 +144,8 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
}
if ( m_queue )
{
connect( m_queue, &LoaderQueue::done, [this]() {
m_queue->deleteLater();
m_queue = nullptr;
} );
m_queue->fetchNext();
connect( m_queue, &LoaderQueue::done, this, &Config::loadingDone );
QMetaObject::invokeMethod( m_queue, "fetchNext", Qt::QueuedConnection );
}
}

View File

@ -83,12 +83,13 @@ Q_SIGNALS:
private Q_SLOTS:
void retranslate();
void loadingDone();
private:
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel = nullptr; // As it appears in the sidebar
CalamaresUtils::Locale::TranslatedString* m_titleLabel = nullptr;
PackageModel* m_model = nullptr;
LoaderQueue* m_queue;
LoaderQueue* m_queue = nullptr;
Status m_status = Status::Ok;
bool m_required = false;
};

View File

@ -95,6 +95,12 @@ LoaderQueue::fetch( const QUrl& url )
}
}
/** @brief Call fetchNext() on the queue if it can
*
* 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.
*/
class FetchNextUnless
{
public: