summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-01-06 13:29:23 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-01-11 10:50:19 +0000
commit74883726deeebea14faca65663339271f1c2c547 (patch)
treed085f28f47c86d6dae2adff7786b159a87a75755 /tests
parent7ae530a1e013463cd24e13b2b3c5eb86528c7cb7 (diff)
Fix segfaults when failing to fetch compressed repositories
The ComponentModel object was not always reset in case we already got to the point of clearing the source data (deleted components owned by PackageManagerCore from previous fetch) and failed after that, leaving the model with dangling pointers to the deleted component objects. If we were already on ComponentSelectionPage, this would cause segmentation faults when the component tree view using the model would be shown again after fetch. Task-number: QTIFW-2441 Change-Id: Ie779de5ca0a3c4ae895ea507e6be4a2f7343501e Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/brokeninstaller/tst_brokeninstaller.cpp6
-rw-r--r--tests/auto/installer/componentmodel/tst_componentmodel.cpp24
2 files changed, 15 insertions, 15 deletions
diff --git a/tests/auto/installer/brokeninstaller/tst_brokeninstaller.cpp b/tests/auto/installer/brokeninstaller/tst_brokeninstaller.cpp
index 95f4ac77d..43bd15288 100644
--- a/tests/auto/installer/brokeninstaller/tst_brokeninstaller.cpp
+++ b/tests/auto/installer/brokeninstaller/tst_brokeninstaller.cpp
@@ -100,7 +100,7 @@ private slots:
QList<Component*> rootComponents = loadComponents(core);
ComponentModel *model = new ComponentModel(1, &core);
- model->setRootComponents(rootComponents);
+ model->reset(rootComponents);
// all names should be resolvable
QStringList all;
all << m_checkedComponentsWithBrokenScript << m_uncheckedComponentsWithBrokenScript << m_partiallyCheckedComponentsWithBrokenScript;
@@ -127,7 +127,7 @@ private slots:
QTest::ignoreMessage(QtWarningMsg, re);
invalidScriptComponent->loadComponentScript(":///data/broken_script.qs");
- model->setRootComponents(components);
+ model->reset(components);
testModelState(model, m_checkedComponentsWithBrokenScript, m_partiallyCheckedComponentsWithBrokenScript, m_uncheckedComponentsWithBrokenScript);
}
@@ -146,7 +146,7 @@ private slots:
componentDependingOnMissingDependency->addDependency("componentmissingdependency");
core.componentsToInstallNeedsRecalculation();
- model->setRootComponents(components);
+ model->reset(components);
testModelState(model, m_checkedComponentsWithMissingDependency, m_partiallyCheckedComponentsWithBrokenScript, m_uncheckedComponentsWithMissingDependency);
}
diff --git a/tests/auto/installer/componentmodel/tst_componentmodel.cpp b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
index 3aef34fe4..463485d96 100644
--- a/tests/auto/installer/componentmodel/tst_componentmodel.cpp
+++ b/tests/auto/installer/componentmodel/tst_componentmodel.cpp
@@ -92,7 +92,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
// all names should be resolvable, virtual components are not indexed if they are not visible
QStringList all;
@@ -116,7 +116,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
// all names should be resolvable, including virtual components
QStringList all;
@@ -141,7 +141,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
QCOMPARE(model.core(), &m_core);
@@ -162,7 +162,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked);
@@ -184,7 +184,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked);
@@ -204,7 +204,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
QCOMPARE(model.checkedState(), ComponentModel::DefaultChecked);
@@ -226,7 +226,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
// select all possible components.
@@ -262,7 +262,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
// select all possible components.
@@ -300,7 +300,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
// select all possible components.
@@ -335,7 +335,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
// select all possible components.
@@ -379,7 +379,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
const QModelIndex root = model.indexFromComponentName(vendorProduct);
QCOMPARE(model.data(root, Qt::DisplayRole).toString(), expectedName);
@@ -397,7 +397,7 @@ private slots:
// setup the model with 1 column
ComponentModel model(1, &m_core);
- model.setRootComponents(rootComponents);
+ model.reset(rootComponents);
testDefaultInheritedModelBehavior(&model, 1);
model.setCheckedState(ComponentModel::DefaultChecked);