Issue a warning when a component depends on auto dependent one.

Task-number: QTIFW-510
Change-Id: I57eff879deebf8f31a472a6c66a7e275e34447bd
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
Jarek Kobus 2015-03-10 17:01:26 +01:00
parent dd2c70b10d
commit 8c2941ae58
2 changed files with 30 additions and 3 deletions

View File

@ -42,6 +42,7 @@ namespace QInstaller {
QStringList ComponentChecker::checkComponent(Component *component)
{
PackageManagerCore *core = component->packageManagerCore();
QStringList checkResult;
const bool defaultPropertyScriptValue = component->variables().value(scDefault).compare(scScript, Qt::CaseInsensitive) == 0;
@ -62,6 +63,11 @@ QStringList ComponentChecker::checkComponent(Component *component)
"with \"AutoDependOn\" list. This combination of states may not work properly.")
.arg(component->name());
}
if (!core->dependees(component).isEmpty()) {
checkResult << QString::fromLatin1("Other components depend on auto dependent "
"component %1. This may not work properly.")
.arg(component->name());
}
}
if (component->packageManagerCore()->isInstaller()) {
if (component->isTristate()) {
@ -105,7 +111,6 @@ QStringList ComponentChecker::checkComponent(Component *component)
.arg(component->name());
}
PackageManagerCore *core = component->packageManagerCore();
if (!core->dependees(component).isEmpty()) {
checkResult << QString::fromLatin1("Other components depend on component %1 "
"which has children components. This will not work properly.")
@ -113,6 +118,7 @@ QStringList ComponentChecker::checkComponent(Component *component)
}
}
}
return checkResult;
}

View File

@ -269,15 +269,36 @@ private slots:
componentB->setValue(QLatin1String("AutoDependOn"), QLatin1String("A"));
componentB->setValue(QLatin1String("Default"), QLatin1String("true"));
core->appendRootComponent(componentA);
core->appendRootComponent(componentB);
ComponentToStringList result;
result[componentB].append(QLatin1String("Component B specifies \"Default\" property "
"together with \"AutoDependOn\" list. This combination of states "
"may not work properly."));
"together with \"AutoDependOn\" list. This combination of states "
"may not work properly."));
QTest::newRow("AutoDepend and default")
<< (QList<Component *>() << componentA << componentB)
<< result;
NamedComponent *componentC = new NamedComponent(core, QLatin1String("C"));
NamedComponent *componentD = new NamedComponent(core, QLatin1String("D"));
NamedComponent *componentE = new NamedComponent(core, QLatin1String("E"));
componentD->setValue(QLatin1String("AutoDependOn"), QLatin1String("C"));
componentE->addDependency(QLatin1String("D"));
core->appendRootComponent(componentC);
core->appendRootComponent(componentD);
core->appendRootComponent(componentE);
result.clear();
result[componentD].append(QLatin1String("Other components depend on auto dependent "
"component D. This may not work properly."));
QTest::newRow("AutoDepend and dependency")
<< (QList<Component *>() << componentC << componentD << componentE)
<< result;
}
void checkComponent()