Package::indexOfvariant works on fully-qualified IDs.
Should fix issues restoring variants in the launcher.
This commit is contained in:
parent
1c39daec07
commit
5a0908d5bb
@ -175,10 +175,14 @@ int parseTest()
|
|||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int skisVariantFull = p2->indexOfVariant("org.flightgear.test.catalog1.c172p-skis");
|
||||||
|
VERIFY(skisVariantFull > 0);
|
||||||
|
|
||||||
unsigned int skisVariant = p2->indexOfVariant("c172p-skis");
|
unsigned int skisVariant = p2->indexOfVariant("c172p-skis");
|
||||||
VERIFY(skisVariant > 0);
|
VERIFY(skisVariant > 0);
|
||||||
|
|
||||||
|
COMPARE(skisVariant, skisVariantFull);
|
||||||
|
|
||||||
COMPARE(p2->getLocalisedProp("description", skisVariant), "A plane with skis");
|
COMPARE(p2->getLocalisedProp("description", skisVariant), "A plane with skis");
|
||||||
COMPARE(p2->getLocalisedProp("author", skisVariant), "Standard author");
|
COMPARE(p2->getLocalisedProp("author", skisVariant), "Standard author");
|
||||||
|
|
||||||
|
@ -340,13 +340,25 @@ std::string Package::nameForVariant(const std::string& vid) const
|
|||||||
|
|
||||||
unsigned int Package::indexOfVariant(const std::string& vid) const
|
unsigned int Package::indexOfVariant(const std::string& vid) const
|
||||||
{
|
{
|
||||||
if (vid == id()) {
|
// accept fully-qualified IDs here
|
||||||
|
std::string actualId = vid;
|
||||||
|
size_t lastDot = vid.rfind('.');
|
||||||
|
if (lastDot != std::string::npos) {
|
||||||
|
std::string catalogId = vid.substr(0, lastDot);
|
||||||
|
if (catalogId != catalog()->id()) {
|
||||||
|
throw sg_exception("Bad fully-qualified ID:" + vid + ", package mismatch" );
|
||||||
|
}
|
||||||
|
actualId = vid.substr(lastDot + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (actualId == id()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int result = 1;
|
unsigned int result = 1;
|
||||||
for (SGPropertyNode* var : m_props->getChildren("variant")) {
|
for (SGPropertyNode* var : m_props->getChildren("variant")) {
|
||||||
if (var->getStringValue("id") == vid) {
|
if (var->getStringValue("id") == actualId) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user