summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2018-09-24 10:10:56 +0300
committerKatja Marttila <katja.marttila@qt.io>2018-09-27 08:13:51 +0000
commit0e9909532f61f2fa18b9fb480bdc4b3f94bfc632 (patch)
treed25154d8bdc18dd9a798d8d68a32a1e78413ad38
parent2e42e535206ff9ff9fecc9af9cf51ccb2bb6edae (diff)
Add signal to inform about unstable components
Task-number: QTIFW-1197 Change-Id: If9d7941f4c7bfc478daa83dcd73dfa71c9163561 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--examples/unstablecomponent/config/config.xml1
-rw-r--r--examples/unstablecomponent/config/controller.qs10
-rw-r--r--src/libs/installer/component.cpp8
-rw-r--r--src/libs/installer/component.h5
-rw-r--r--src/libs/installer/installercalculator.cpp2
-rw-r--r--src/libs/installer/packagemanagercore.cpp6
-rw-r--r--src/libs/installer/packagemanagercore.h9
7 files changed, 32 insertions, 9 deletions
diff --git a/examples/unstablecomponent/config/config.xml b/examples/unstablecomponent/config/config.xml
index bd9ac49ea..fb42ae334 100644
--- a/examples/unstablecomponent/config/config.xml
+++ b/examples/unstablecomponent/config/config.xml
@@ -7,4 +7,5 @@
<StartMenuDir>Qt IFW Examples</StartMenuDir>
<TargetDir>@HomeDir@/IfwExamples/unstablecomponent</TargetDir>
<AllowUnstableComponents>true</AllowUnstableComponents>
+ <ControlScript>controller.qs</ControlScript>
</Installer>
diff --git a/examples/unstablecomponent/config/controller.qs b/examples/unstablecomponent/config/controller.qs
new file mode 100644
index 000000000..ea7f96802
--- /dev/null
+++ b/examples/unstablecomponent/config/controller.qs
@@ -0,0 +1,10 @@
+function Controller() {
+ installer.unstableComponentFound.connect(unstableComponentFound)
+}
+
+unstableComponentFound = function(type, message, comp)
+{
+ console.log("Unstable component, type: " + type)
+ console.log("Unstable component, message: " + message)
+ console.log("Unstable component, name: " + comp)
+}
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index feedad737..5a508f118 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -524,12 +524,12 @@ void Component::loadComponentScript(const QString &fileName)
Component *dependencyComponent = packageManagerCore()->componentByName
(PackageManagerCore::checkableName(dependency));
if (dependencyComponent && dependencyComponent->isUnstable())
- setUnstable();
+ setUnstable(PackageManagerCore::UnstableError::DepencyToUnstable, QLatin1String("Dependent on unstable component"));
}
}
} catch (const Error &error) {
if (packageManagerCore()->settings().allowUnstableComponents()) {
- setUnstable();
+ setUnstable(PackageManagerCore::UnstableError::ScriptLoadingFailed, error.message());
qWarning() << error.message();
} else {
throw error;
@@ -1380,7 +1380,7 @@ bool Component::isUnstable() const
return scTrue == d->m_vars.value(scUnstable);
}
-void Component::setUnstable()
+void Component::setUnstable(PackageManagerCore::UnstableError error, const QString &errorMessage)
{
QList<Component*> dependencies = d->m_core->dependees(this);
// Mark this component unstable
@@ -1398,6 +1398,8 @@ void Component::setUnstable()
foreach (Component *descendant, this->descendantComponents()) {
descendant->markComponentUnstable();
}
+ QMetaEnum metaEnum = QMetaEnum::fromType<PackageManagerCore::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 574117b6d..e6bc4874d 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -32,6 +32,7 @@
#include "constants.h"
#include "component_p.h"
#include "qinstallerglobal.h"
+#include "packagemanagercore.h"
#include <QtCore/QDir>
#include <QtCore/QMetaType>
@@ -43,8 +44,6 @@ QT_FORWARD_DECLARE_CLASS(QQmlV4Function)
namespace QInstaller {
-class PackageManagerCore;
-
class INSTALLER_EXPORT Component : public QObject, public ComponentModelHelper
{
Q_OBJECT
@@ -184,7 +183,7 @@ public:
Q_INVOKABLE bool componentChangeRequested();
bool isUnstable() const;
- void setUnstable();
+ void setUnstable(PackageManagerCore::UnstableError error, const QString &errorMessage = QString());
bool isVirtual() const;
bool isSelected() const;
diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp
index 7767b5d96..db1f88563 100644
--- a/src/libs/installer/installercalculator.cpp
+++ b/src/libs/installer/installercalculator.cpp
@@ -171,7 +171,7 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q
qWarning().noquote() << errorMessage;
m_componentsToInstallError.append(errorMessage);
if (component->packageManagerCore()->settings().allowUnstableComponents()) {
- component->setUnstable();
+ component->setUnstable(PackageManagerCore::UnstableError::MissingDependency, errorMessage);
continue;
} else {
return false;
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 44025de55..97ffc8dd1 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2575,8 +2575,10 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo
// Check if there are sha checksum mismatch. Component will still show in install tree
// but is unselectable.
foreach (const QString packageName, d->m_metadataJob.shaMismatchPackages()) {
- if (packageName == component->name())
- component->setUnstable();
+ if (packageName == component->name()) {
+ QString errorString = QLatin1String("SHA mismatch detected for component ") + packageName;
+ component->setUnstable(PackageManagerCore::UnstableError::ShaMismatch, errorString);
+ }
}
}
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index 10aad54d1..c05374ce9 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -65,6 +65,14 @@ public:
Protocol::Mode mode = Protocol::Mode::Production);
~PackageManagerCore();
+ enum UnstableError {
+ DepencyToUnstable = 0,
+ ShaMismatch,
+ ScriptLoadingFailed,
+ MissingDependency
+ };
+ Q_ENUM(UnstableError)
+
// status
enum Status {
Success = EXIT_SUCCESS,
@@ -323,6 +331,7 @@ Q_SIGNALS:
void coreNetworkSettingsChanged();
void guiObjectChanged(QObject *gui);
+ void unstableComponentFound(const QString &type, const QString &errorMessage, const QString &component);
private:
struct Data {