[netinstall] Removing the last package should clear it out.

FIXES #1577
This commit is contained in:
Adriaan de Groot 2020-11-18 17:27:50 +01:00
parent ff2d2d0d45
commit 66da5f2fa4

View File

@ -139,6 +139,7 @@ NetInstallViewStep::onLeave()
// Clear out existing operations for this module, going backwards: // Clear out existing operations for this module, going backwards:
// Sometimes we remove an item, and we don't want the index to // Sometimes we remove an item, and we don't want the index to
// fall off the end of the list. // fall off the end of the list.
bool somethingRemoved = false;
for ( int index = packageOperations.length() - 1; 0 <= index; index-- ) for ( int index = packageOperations.length() - 1; 0 <= index; index-- )
{ {
const QVariantMap op = packageOperations.at( index ).toMap(); const QVariantMap op = packageOperations.at( index ).toMap();
@ -146,6 +147,7 @@ NetInstallViewStep::onLeave()
{ {
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey(); cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
packageOperations.removeAt( index ); packageOperations.removeAt( index );
somethingRemoved = true;
} }
} }
@ -183,7 +185,7 @@ NetInstallViewStep::onLeave()
cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages."; cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages.";
} }
if ( !packageOperations.isEmpty() ) if ( somethingRemoved || !packageOperations.isEmpty() )
{ {
gs->insert( PACKAGEOP, packageOperations ); gs->insert( PACKAGEOP, packageOperations );
} }