Catalogs: fix enabling/disabling
Relates to bug Michael found in the launcher: https://sourceforge.net/p/flightgear/codetickets/2380/
This commit is contained in:
parent
c0323e34a5
commit
ed8ff68114
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user