Validate JSON parsing results

Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
Yihe Li 2025-06-02 07:36:53 +08:00
parent 0a1001ee84
commit 50fb2db718
No known key found for this signature in database
2 changed files with 13 additions and 12 deletions

View file

@ -686,18 +686,7 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)
}
qDebug() << "Loaded instance" << inst->name() << "from" << inst->instanceRoot();
// Fixup the shortcuts by pruning all non-existing links
auto shortcut = inst->shortcuts();
for (auto it = shortcut.begin(); it != shortcut.end();) {
const auto& [name, filePath, target] = *it;
if (!QDir(filePath).exists()) {
qWarning() << "Shortcut" << name << "have non-existent path" << filePath;
it = shortcut.erase(it);
continue;
}
++it;
}
inst->setShortcuts(shortcut);
if (!shortcut.isEmpty())
qDebug() << "Loaded" << shortcut.size() << "shortcut(s) for instance" << inst->name();