Catalogs: fix enabling/disabling

Relates to bug Michael found in the launcher:
https://sourceforge.net/p/flightgear/codetickets/2380/
This commit is contained in:
Automatic Release Builder 2020-09-30 14:38:35 +01:00
parent 0ab81d36b9
commit dab015742a
2 changed files with 18 additions and 11 deletions

View File

@ -595,13 +595,17 @@ void Catalog::setUserEnabled(bool b)
m_userEnabled = b;
SGPath disableMarkerFile = installRoot() / "_disabled_";
if (m_userEnabled) {
sg_ofstream of(disableMarkerFile);
of << "1\n"; // touch the file
if (m_userEnabled == false) {
sg_ofstream of(disableMarkerFile, std::ios::trunc | std::ios::out);
of << "1" << std::flush; // touch the file
of.close();
} else {
bool ok = disableMarkerFile.remove();
if (disableMarkerFile.exists()) {
const bool ok = disableMarkerFile.remove();
if (!ok) {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed to remove catalog-disable marker file:" << disableMarkerFile);
SG_LOG(SG_IO, SG_WARN, "Failed to remove catalog-disable marker file:" << disableMarkerFile);
}
}
}

View File

@ -690,7 +690,10 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason)
d->refreshing.erase(aCat);
}
if ((aReason == Delegate::STATUS_REFRESHED) && (catIt == d->catalogs.end())) {
if (aCat->isUserEnabled() &&
(aReason == Delegate::STATUS_REFRESHED) &&
(catIt == d->catalogs.end()))
{
assert(!aCat->id().empty());
d->catalogs.insert(catIt, CatalogDict::value_type(aCat->id(), aCat));
@ -705,7 +708,7 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason)
}
if (!aCat->isEnabled()) {
// catalog has errors, disable it
// catalog has errors or was disabled by user, disable it
auto j = std::find(d->disabledCatalogs.begin(),
d->disabledCatalogs.end(),
aCat);