Small fixes to the .wps loading, return nullptr instead of OSFatal, add asserts instead of OSFatal

This commit is contained in:
Maschell
2024-05-08 17:49:25 +02:00
parent 6855564c28
commit 43a18b56d7
4 changed files with 23 additions and 18 deletions

View File

@@ -11,22 +11,15 @@ CategoryRenderer::CategoryRenderer(const GeneralConfigInformation *info, const W
for (uint32_t i = 0; i < cat->getCategories().size() + cat->getItems().size(); i++) {
if (i < cat->getCategories().size()) {
auto item = make_unique_nothrow<ConfigRendererItemCategory>(cat->getCategories()[i].get());
if (!item) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItemCategory");
}
assert(item);
mItemRenderer.push_back(std::move(item));
} else {
auto itemIndex = (int32_t) (i - cat->getCategories().size());
if (itemIndex < 0 || itemIndex >= (int32_t) cat->getItems().size()) {
DEBUG_FUNCTION_LINE_ERR("unexpected index");
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() unexpected index");
assert(false);
}
auto item = make_unique_nothrow<ConfigRendererItem>(cat->getItems()[itemIndex].get());
if (!item) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ConfigRendererItemCategory");
OSFatal("WiiUPluginBackend::CategoryRenderer::CategoryRenderer() Failed to alloc ConfigRendererItem");
}
assert(item);
mItemRenderer.push_back(std::move(item));
}
}