summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2022-05-05 06:58:48 +0300
committerKatja Marttila <katja.marttila@qt.io>2022-05-05 20:06:07 +0300
commit54a1327bd1fdaafa36c2c2324beafb0fad338f47 (patch)
treecfaca45106e646d1ef9064ecc484048e375599d6
parentf500ac33c5d1a479cfb90b2fe2d1f915b073f032 (diff)
Remove unnecessary unstable calculation
Removed unnecessary dependency component calculation for unstable components. We mark the dependee components unstable already in setUnstable() -function where we mark the original component unstable. This change speeds up building the component tree from zero to fifty percent depending on the number of script all components have. Task-number: QTIFW-2626 Change-Id: I11b35cfd981cea8b8ed958a5af51b695cc47e9c5 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--src/libs/installer/component.cpp28
-rw-r--r--src/libs/installer/component.h5
2 files changed, 13 insertions, 20 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 87ec3e4bf..100e95cee 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -611,17 +611,6 @@ void Component::loadComponentScript(const QString &fileName)
d->m_scriptContext = d->scriptEngine()->loadInContext(QLatin1String("Component"), fileName,
QString::fromLatin1("var component = installer.componentByName('%1'); component.name;")
.arg(name()));
- if (packageManagerCore()->settings().allowUnstableComponents()) {
- // Check if component has dependency to a broken component. Dependencies to broken
- // components are checked if error is thrown but if dependency to a broken
- // component is added in script, the script might not be loaded yet
- foreach (QString dependency, dependencies()) {
- Component *dependencyComponent = packageManagerCore()->componentByName
- (PackageManagerCore::checkableName(dependency));
- if (dependencyComponent && dependencyComponent->isUnstable())
- setUnstable(Component::UnstableError::DepencyToUnstable, QLatin1String("Dependent on unstable component"));
- }
- }
} catch (const Error &error) {
if (packageManagerCore()->settings().allowUnstableComponents()) {
setUnstable(Component::UnstableError::ScriptLoadingFailed, error.message());
@@ -1177,7 +1166,7 @@ Operation *Component::createOperation(const QString &operationName, const QStrin
return operation;
}
-void Component::markComponentUnstable()
+void Component::markComponentUnstable(Component::UnstableError error, const QString &errorMessage)
{
setValue(scDefault, scFalse);
// Mark unstable component unchecked if:
@@ -1190,6 +1179,8 @@ void Component::markComponentUnstable()
if (d->m_core->isInstaller() || !isInstalled() || d->m_core->isUpdater())
setCheckState(Qt::Unchecked);
setValue(scUnstable, scTrue);
+ QMetaEnum metaEnum = QMetaEnum::fromType<Component::UnstableError>();
+ emit packageManagerCore()->unstableComponentFound(QLatin1String(metaEnum.valueToKey(error)), errorMessage, this->name());
}
namespace {
@@ -1579,22 +1570,23 @@ void Component::setUnstable(Component::UnstableError error, const QString &error
{
QList<Component*> dependencies = d->m_core->dependees(this);
// Mark this component unstable
- markComponentUnstable();
+ markComponentUnstable(error, errorMessage);
// Marks all components unstable that depend on the unstable component
foreach (Component *dependency, dependencies) {
- dependency->markComponentUnstable();
+ dependency->markComponentUnstable(UnstableError::DepencyToUnstable,
+ QLatin1String("Dependent on unstable component"));
foreach (Component *descendant, dependency->descendantComponents()) {
- descendant->markComponentUnstable();
+ descendant->markComponentUnstable(UnstableError::DescendantOfUnstable,
+ QLatin1String("Descendant of unstable component"));
}
}
// Marks all child components unstable
foreach (Component *descendant, this->descendantComponents()) {
- descendant->markComponentUnstable();
+ descendant->markComponentUnstable(UnstableError::DescendantOfUnstable,
+ QLatin1String("Descendant of unstable component"));
}
- QMetaEnum metaEnum = QMetaEnum::fromType<Component::UnstableError>();
- emit packageManagerCore()->unstableComponentFound(QLatin1String(metaEnum.valueToKey(error)), errorMessage, this->name());
}
/*!
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 203856c0e..1e83a1e9e 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -73,7 +73,8 @@ public:
ShaMismatch,
ScriptLoadingFailed,
MissingDependency,
- InvalidTreeName
+ InvalidTreeName,
+ DescendantOfUnstable
};
Q_ENUM(UnstableError)
@@ -230,7 +231,7 @@ private:
const QString &parameter8 = QString(), const QString &parameter9 = QString(),
const QString &parameter10 = QString());
Operation *createOperation(const QString &operationName, const QStringList &parameters);
- void markComponentUnstable();
+ void markComponentUnstable(const Component::UnstableError error, const QString &errorMessage);
private:
QString validatorCallbackName;