From 03d086a2333ea8a2858662debcc4cee9d89b3d24 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 19 Mar 2021 11:41:47 +0100 Subject: [PATCH] [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 --- src/modules/netinstall/Config.cpp | 18 +++++++++++++----- src/modules/netinstall/Config.h | 3 ++- src/modules/netinstall/LoaderQueue.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index 491443654..5f703f8d4 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -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 ); } } diff --git a/src/modules/netinstall/Config.h b/src/modules/netinstall/Config.h index b8e258eff..d4c3c6f19 100644 --- a/src/modules/netinstall/Config.h +++ b/src/modules/netinstall/Config.h @@ -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; }; diff --git a/src/modules/netinstall/LoaderQueue.cpp b/src/modules/netinstall/LoaderQueue.cpp index 7236b4096..98245dead 100644 --- a/src/modules/netinstall/LoaderQueue.cpp +++ b/src/modules/netinstall/LoaderQueue.cpp @@ -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: