From 9002c943459a1033bc8589c4188f0e6988b7fca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 25 Oct 2014 10:58:08 +0200 Subject: [PATCH] Package Kit: Always allocate local repository Consequently always register it with the solver in Init(). This solves the problem that it made a difference at which time Init() is called. Init() is called at the beginning of Install() and Uninstall(), but HaikuDepot was calling it before that for other reasons. A second call to Init() will exit early. If local package files were added to the PackageManager instance, the local repository was created lazily, but because Init() did not run a second time, the local repository was not registered with the solver. Now it already is, since it is no longer created on demand, but always. --- src/kits/package/manager/PackageManager.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/kits/package/manager/PackageManager.cpp b/src/kits/package/manager/PackageManager.cpp index 44044d224e..091318d807 100644 --- a/src/kits/package/manager/PackageManager.cpp +++ b/src/kits/package/manager/PackageManager.cpp @@ -59,7 +59,7 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location, B_PACKAGE_INSTALLATION_LOCATION_HOME, -3)), fInstalledRepositories(10), fOtherRepositories(10, true), - fLocalRepository(NULL), + fLocalRepository(new (std::nothrow) MiscLocalRepository), fTransactions(5, true), fInstallationInterface(installationInterface), fUserInteractionHandler(userInteractionHandler) @@ -87,11 +87,12 @@ BPackageManager::Init(uint32 flags) if (error != B_OK) DIE(error, "failed to create solver"); - if (fSystemRepository == NULL || fHomeRepository == NULL) + if (fSystemRepository == NULL || fHomeRepository == NULL + || fLocalRepository == NULL) { throw std::bad_alloc(); + } - if (fLocalRepository != NULL) - BRepositoryBuilder(*fLocalRepository).AddToSolver(fSolver, false); + BRepositoryBuilder(*fLocalRepository).AddToSolver(fSolver, false); // add installation location repositories if ((flags & B_ADD_INSTALLED_REPOSITORIES) != 0) { @@ -763,10 +764,8 @@ BPackageManager::_IsLocalPackage(const char* fileName) BSolverPackage* BPackageManager::_AddLocalPackage(const char* fileName) { - // We need a local repository. if (fLocalRepository == NULL) - fLocalRepository = new MiscLocalRepository; - + throw std::bad_alloc(); return fLocalRepository->AddLocalPackage(fileName); }