mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
When reading, don't add items to a vector before they are read. This avoids nullptrs in the list of fields, cards, etc. when exceptions are thrown
This commit is contained in:
@@ -217,9 +217,10 @@ template <typename T>
|
|||||||
void Reader::handle(const Char* name, vector<T>& vector) {
|
void Reader::handle(const Char* name, vector<T>& vector) {
|
||||||
String vectorKey = singular_form(name);
|
String vectorKey = singular_form(name);
|
||||||
while (enterBlock(vectorKey.c_str())) {
|
while (enterBlock(vectorKey.c_str())) {
|
||||||
vector.resize(vector.size() + 1);
|
T item;
|
||||||
handle_greedy(vector.back());
|
handle_greedy(item);
|
||||||
update_index(vector.back(), vector.size() - 1); // update index for IndexMap
|
update_index(item, vector.size()); // update index for IndexMap
|
||||||
|
vector.emplace_back(std::move(item));
|
||||||
exitBlock();
|
exitBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user