Commit 49c245cb authored by Volker Krause's avatar Volker Krause
Browse files

Don't add null nodes to the document node tree

parent 8e87dea7
......@@ -26,6 +26,7 @@ class ExtractorDocumentNodeTest : public QObject
private Q_SLOTS:
void testBasics()
{
ExtractorDocumentNodeFactory factory;
ExtractorDocumentNode node;
QVERIFY(node.isNull());
node = {};
......@@ -36,8 +37,10 @@ private Q_SLOTS:
node.setContextDateTime(QDateTime::currentDateTime());
QVERIFY(node.isNull()); // not properly constructed
ExtractorDocumentNode child;
auto child = factory.createNode(QVariant::fromValue(QByteArray("data")), u"application/octet-stream");
QVERIFY(!child.isNull());
node.appendChild(child);
QCOMPARE(node.childNodes().size(), 1);
QCOMPARE(child.parent().mimeType(), QLatin1String("text/plain"));
QVERIFY(child.contextDateTime().isValid());
QCOMPARE(child.contextDateTime(), node.contextDateTime());
......
......@@ -133,6 +133,9 @@ const std::vector<ExtractorDocumentNode>& ExtractorDocumentNode::childNodes() co
void ExtractorDocumentNode::appendChild(ExtractorDocumentNode &child)
{
if (child.isNull()) {
return;
}
child.setParent(*this);
d->childNodes.push_back(child);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment