summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-06-03 18:51:17 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-06-16 11:28:59 +0000
commit78798b58b23b543cee54a9fc307293f0f4e51afe (patch)
tree4398ed0f57883553bdae67bfe28755359e96564f
parent115ad31febdb5a478a3fd90ec4f3d9a1b59180e4 (diff)
Display progress for loading component install scripts
Also process pending events for the main thread in the loop that calls Component::loadComponentScript() repeatedly, to not block the UI while busy loading the scripts. Task-number: QTIFW-2701 Change-Id: I4a1dd8e2441e21b5075b6fdffff8a47cd4bc7c80 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r--src/libs/installer/packagemanagercore.cpp10
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp30
-rw-r--r--src/libs/installer/packagemanagercore_p.h3
3 files changed, 36 insertions, 7 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index c96083f5d..a5bf98000 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -4268,21 +4268,25 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const
}
// after everything is set up, load the scripts
+ if (!d->loadComponentScripts(components))
+ return false;
+
foreach (QInstaller::Component *component, components) {
if (d->statusCanceledOrFailed())
return false;
- component->loadComponentScript();
if (!component->isUnstable() && component->autoDependencies().isEmpty())
component->setCheckState(Qt::Checked);
}
+ // even for possible dependencies we need to load the scripts for example to get archives
+ if (!d->loadComponentScripts(d->m_updaterComponentsDeps))
+ return false;
+
// after everything is set up, check installed components
foreach (QInstaller::Component *component, d->m_updaterComponentsDeps) {
if (d->statusCanceledOrFailed())
return false;
- // even for possible dependency we need to load the script for example to get archives
- component->loadComponentScript();
if (component->isInstalled() && !component->autoDependencies().isEmpty()) {
// since we do not put them into the model, which would force a update of e.g. tri state
// components, we have to check all installed components ourselves
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 5e4ee6ffb..1d4302e12 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -402,10 +402,9 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash<QString, Component*> &c
// after everything is set up, load the scripts if needed and create helper hashes
// for autodependency and dependency components for quicker search later
- foreach (QInstaller::Component *component, components) {
- if (loadScript)
- component->loadComponentScript();
- }
+ if (loadScript && !loadComponentScripts(components))
+ return false;
+
// now we can preselect components in the tree
foreach (QInstaller::Component *component, components) {
// set the checked state for all components without child (means without tristate)
@@ -458,6 +457,29 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash<QString, Component*> &c
return true;
}
+template <typename T>
+bool PackageManagerCorePrivate::loadComponentScripts(const T &components)
+{
+ infoMessage(nullptr, tr("Loading component scripts..."));
+
+ quint64 loadedComponents = 0;
+ for (auto *component : components) {
+ if (statusCanceledOrFailed())
+ return false;
+
+ component->loadComponentScript();
+ ++loadedComponents;
+
+ const int currentProgress = qRound(double(loadedComponents) / components.count() * 100);
+ infoProgress(nullptr, currentProgress, 100);
+ qApp->processEvents();
+ }
+ return true;
+}
+
+template bool PackageManagerCorePrivate::loadComponentScripts<QList<Component *>>(const QList<Component *> &);
+template bool PackageManagerCorePrivate::loadComponentScripts<QHash<QString, Component *>>(const QHash<QString, Component *> &);
+
void PackageManagerCorePrivate::cleanUpComponentEnvironment()
{
m_componentReplaces.clear();
diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h
index 24782b598..0ce081774 100644
--- a/src/libs/installer/packagemanagercore_p.h
+++ b/src/libs/installer/packagemanagercore_p.h
@@ -106,6 +106,9 @@ public:
bool buildComponentTree(QHash<QString, Component*> &components, bool loadScript);
+ template <typename T>
+ bool loadComponentScripts(const T &components);
+
void cleanUpComponentEnvironment();
ScriptEngine *componentScriptEngine() const;
ScriptEngine *controlScriptEngine() const;