From 0cb1b463e16ccbb86e389e65fb43f0e246ca3db0 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Wed, 11 Nov 2020 19:38:14 +0000 Subject: [PATCH] Catalogs: fix ownership of new Catalogs When doing the initial download of a Catalog, ensure we still keep an owning ref to it. --- simgear/package/Root.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/simgear/package/Root.cxx b/simgear/package/Root.cxx index e358c7d6..49925cbe 100755 --- a/simgear/package/Root.cxx +++ b/simgear/package/Root.cxx @@ -722,12 +722,6 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason) auto catIt = d->catalogs.find(aCat->id()); d->fireRefreshStatus(aCat, aReason); - if (aReason == Delegate::STATUS_IN_PROGRESS) { - d->refreshing.insert(aCat); - } else { - d->refreshing.erase(aCat); - } - if (aCat->isUserEnabled() && (aReason == Delegate::STATUS_REFRESHED) && (catIt == d->catalogs.end())) @@ -761,6 +755,17 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason) } } // of catalog is disabled + // remove from refreshing /after/ checking for enable / disabled, since for + // new catalogs, the reference in d->refreshing might be our /only/ + // reference to the catalog. Once the refresh is done (either failed or + // succeeded) the Catalog will be in either d->catalogs or + // d->disabledCatalogs + if (aReason == Delegate::STATUS_IN_PROGRESS) { + d->refreshing.insert(aCat); + } else { + d->refreshing.erase(aCat); + } + if (d->refreshing.empty()) { d->fireRefreshStatus(CatalogRef(), Delegate::STATUS_REFRESHED); d->firePackagesChanged();