diff --git a/simgear/package/Catalog.cxx b/simgear/package/Catalog.cxx index e6b27a7f..2b57c11e 100644 --- a/simgear/package/Catalog.cxx +++ b/simgear/package/Catalog.cxx @@ -632,6 +632,8 @@ void Catalog::setUserEnabled(bool b) void Catalog::processAlternate(SGPropertyNode_ptr alt) { + m_refreshRequest.reset(); + std::string altId; const auto idPtr = alt->getStringValue("id"); if (idPtr) { @@ -707,8 +709,8 @@ void Catalog::processAlternate(SGPropertyNode_ptr alt) SG_LOG(SG_GENERAL, SG_INFO, "Migrating catalog " << id() << " to new URL:" << altUrl); setUrl(altUrl); - Downloader* dl = new Downloader(this, altUrl); - root()->makeHTTPRequest(dl); + m_refreshRequest = new Downloader(this, altUrl); + root()->makeHTTPRequest(m_refreshRequest); } int Catalog::markPackagesForInstallation(const string_list &packageIds) { diff --git a/simgear/package/CatalogTest.cxx b/simgear/package/CatalogTest.cxx index d0be1561..93ae7ab1 100644 --- a/simgear/package/CatalogTest.cxx +++ b/simgear/package/CatalogTest.cxx @@ -166,7 +166,8 @@ int parseTest() { SGPath rootPath = simgear::Dir::current().path(); rootPath.append("testRoot"); - pkg::Root* root = new pkg::Root(rootPath, "8.1.12"); + + pkg::RootRef root(new pkg::Root(rootPath, "8.1.2")); root->setLocale("de"); pkg::CatalogRef cat = pkg::Catalog::createFromPath(root, SGPath(SRC_DIR "/catalogTest1")); @@ -347,7 +348,6 @@ int parseTest() SG_CHECK_EQUAL(urls.size(), 3); SG_CHECK_EQUAL(urls.at(1), "http://localhost:2000/mirrorB/b737.tar.gz"); - delete root; return EXIT_SUCCESS; } @@ -956,7 +956,7 @@ int parseInvalidTest() { SGPath rootPath = simgear::Dir::current().path(); rootPath.append("testRoot"); - pkg::Root* root = new pkg::Root(rootPath, "8.1.12"); + pkg::RootRef root(new pkg::Root(rootPath, "8.1.12")); pkg::CatalogRef cat = pkg::Catalog::createFromPath(root, SGPath(SRC_DIR "/catalogTestInvalid")); SG_VERIFY(cat.valid()); @@ -1361,25 +1361,25 @@ int main(int argc, char* argv[]) testRefreshCatalog(&cl); testInstallTarPackage(&cl); - + testInstallArchiveType(&cl); - + testDisableDueToVersion(&cl); - + testOfflineMode(&cl); - + testVersionMigrate(&cl); - + updateInvalidToValid(&cl); updateValidToInvalid(&cl); updateInvalidToInvalid(&cl); - + removeInvalidCatalog(&cl); - + testVersionMigrateToId(&cl); testInstallBadPackage(&cl); - + testMirrorsFailure(&cl); testMigrateInstalled(&cl);