Make the launcher defensive about bad add-ons
Tolerate missing add-on data if a bogus add-on is added by the user. https://sourceforge.net/p/flightgear/codetickets/2266/
This commit is contained in:
parent
736485ab76
commit
bb75d24fc0
1 changed files with 18 additions and 1 deletions
|
@ -84,7 +84,17 @@ QVariant AddonsModel::get(int idx, int role) const
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx < m_addonsList.size()) {
|
if (idx >= 0 && idx < m_addonsList.size()) {
|
||||||
auto path = m_addonsList[idx];
|
auto path = m_addonsList[idx];
|
||||||
|
if (!m_addonsMap.contains(path)) {
|
||||||
|
if ((role == PathRole) || (role == Qt::DisplayRole)) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
auto addon = m_addonsMap[path].addon;
|
auto addon = m_addonsMap[path].addon;
|
||||||
|
if (!addon)
|
||||||
|
return {};
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
QString name = QString::fromStdString(addon->getName());
|
QString name = QString::fromStdString(addon->getName());
|
||||||
|
@ -198,6 +208,9 @@ void AddonsModel::enable(int index, bool enable)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto path = m_addonsList[index];
|
auto path = m_addonsList[index];
|
||||||
|
if (!m_addonsMap.contains(path))
|
||||||
|
return;
|
||||||
|
|
||||||
m_addonsMap[path].enable = enable && checkVersion(path);
|
m_addonsMap[path].enable = enable && checkVersion(path);
|
||||||
|
|
||||||
emit modulesChanged();
|
emit modulesChanged();
|
||||||
|
@ -207,6 +220,10 @@ bool AddonsModel::checkVersion(QString path) const
|
||||||
{
|
{
|
||||||
using namespace simgear;
|
using namespace simgear;
|
||||||
|
|
||||||
|
if (!m_addonsMap.contains(path)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the FlightGear version satisfies the add-on requirements
|
// Check that the FlightGear version satisfies the add-on requirements
|
||||||
std::string minFGversion = m_addonsMap[path].addon->getMinFGVersionRequired();
|
std::string minFGversion = m_addonsMap[path].addon->getMinFGVersionRequired();
|
||||||
if (strutils::compare_versions(FLIGHTGEAR_VERSION, minFGversion) < 0) {
|
if (strutils::compare_versions(FLIGHTGEAR_VERSION, minFGversion) < 0) {
|
||||||
|
@ -220,4 +237,4 @@ bool AddonsModel::checkVersion(QString path) const
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue