various: use simpler/smarter XML reading functions

Should address any XML parsing issues and allows for simpler, more maintainable
code. Should also address a crash that could occur when pasting nodes that had
inputs that weren't copied.
This commit is contained in:
itsmattkc
2020-03-17 02:38:17 +11:00
parent 72eb3a5d82
commit a1f5c85f49
16 changed files with 326 additions and 285 deletions
+21 -2
View File
@@ -31,7 +31,26 @@ Node* XMLLoadNode(QXmlStreamReader* reader) {
void XMLConnectNodes(const QHash<quintptr, NodeOutput*>& output_ptrs, const QList<NodeParam::SerializedConnection>& desired_connections)
{
foreach (const NodeParam::SerializedConnection& con, desired_connections) {
NodeParam::ConnectEdge(output_ptrs.value(con.output),
con.input);
NodeOutput* out = output_ptrs.value(con.output);
if (out) {
NodeParam::ConnectEdge(out, con.input);
}
}
}
bool XMLReadNextStartElement(QXmlStreamReader *reader)
{
QXmlStreamReader::TokenType token;
while ((token = reader->readNext()) != QXmlStreamReader::Invalid
&& token != QXmlStreamReader::EndDocument) {
if (reader->isEndElement()) {
return false;
} else if (reader->isStartElement()) {
return true;
}
}
return false;
}