diff --git a/app/common/xmlutils.cpp b/app/common/xmlutils.cpp index 0b219807a..9a874a74a 100644 --- a/app/common/xmlutils.cpp +++ b/app/common/xmlutils.cpp @@ -33,8 +33,8 @@ void XMLConnectNodes(const XMLNodeData &xml_node_data, MultiUndoCommand *command Node *out = xml_node_data.node_ptrs.value(con.output_node); if (out) { - Node::ValueHint hint; - hint.tag = con.output_param; + // Use output param as hint tag since we grandfathered those in + Node::ValueHint hint(con.output_param); if (command) { command->add_child(new NodeEdgeAddCommand(out, con.input)); diff --git a/app/node/block/clip/clip.cpp b/app/node/block/clip/clip.cpp index df5628ef6..a3c7b3ff2 100644 --- a/app/node/block/clip/clip.cpp +++ b/app/node/block/clip/clip.cpp @@ -51,7 +51,7 @@ ClipBlock::ClipBlock() : IgnoreHashingFrom(kReverseInput); PrependInput(kBufferIn, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable)); - SetValueHintForInput(kBufferIn, {NodeValue::kBuffer, -1, QString()}); + SetValueHintForInput(kBufferIn, ValueHint(NodeValue::kBuffer)); } Node *ClipBlock::copy() const diff --git a/app/node/node.cpp b/app/node/node.cpp index 8ebf92a8a..0317c6427 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -1015,12 +1015,7 @@ int Node::InputArraySize(const QString &id) const void Node::Hash(const Node *node, const ValueHint &hint, QCryptographicHash &hash, const NodeGlobals &globals, const VideoParams &video_params) { - if (!hint.type.isEmpty()) { - hash.addData(reinterpret_cast(hint.type.constData()), sizeof(NodeValue::Type) * hint.type.size()); - } - hash.addData(reinterpret_cast(&hint.index), sizeof(hint.index)); - hash.addData(hint.tag.toUtf8()); - + hint.Hash(hash); node->Hash(hash, globals, video_params); } @@ -2468,11 +2463,11 @@ void NodeRemovePositionFromAllContextsCommand::undo() void Node::ValueHint::Hash(QCryptographicHash &hash) const { // Add value hint - foreach (NodeValue::Type t, type) { - hash.addData(reinterpret_cast(&t), sizeof(t)); + if (!types().isEmpty()) { + hash.addData(reinterpret_cast(types().constData()), sizeof(NodeValue::Type) * types().size()); } - hash.addData(reinterpret_cast(&index), sizeof(index)); - hash.addData(tag.toUtf8()); + hash.addData(reinterpret_cast(&index()), sizeof(index())); + hash.addData(tag().toUtf8()); } void Node::ValueHint::Load(QXmlStreamReader *reader) @@ -2481,15 +2476,15 @@ void Node::ValueHint::Load(QXmlStreamReader *reader) if (reader->name() == QStringLiteral("types")) { while (XMLReadNextStartElement(reader)) { if (reader->name() == QStringLiteral("type")) { - type.append(static_cast(reader->readElementText().toInt())); + type_.append(static_cast(reader->readElementText().toInt())); } else { reader->skipCurrentElement(); } } } else if (reader->name() == QStringLiteral("index")) { - index = reader->readElementText().toInt(); + index_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("tag")) { - tag = reader->readElementText(); + tag_ = reader->readElementText(); } else { reader->skipCurrentElement(); } @@ -2500,15 +2495,15 @@ void Node::ValueHint::Save(QXmlStreamWriter *writer) const { writer->writeStartElement(QStringLiteral("types")); - for (auto it=type.cbegin(); it!=type.cend(); it++) { + for (auto it=type_.cbegin(); it!=type_.cend(); it++) { writer->writeTextElement(QStringLiteral("type"), QString::number(*it)); } writer->writeEndElement(); // types - writer->writeTextElement(QStringLiteral("index"), QString::number(index)); + writer->writeTextElement(QStringLiteral("index"), QString::number(index_)); - writer->writeTextElement(QStringLiteral("tag"), tag); + writer->writeTextElement(QStringLiteral("tag"), tag_); } } diff --git a/app/node/node.h b/app/node/node.h index a5ed6e669..0fb10a9f8 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -462,15 +462,51 @@ public: int InputArraySize(const QString& id) const; - struct ValueHint { - QVector type; - int index = -1; - QString tag; + class ValueHint { + public: + explicit ValueHint(const QVector &types = QVector(), int index = -1, const QString &tag = QString()) : + type_(types), + index_(index), + tag_(tag) + { + } + + explicit ValueHint(const QVector &types, const QString &tag) : + type_(types), + index_(-1), + tag_(tag) + { + } + + explicit ValueHint(int index) : + index_(index) + { + } + + explicit ValueHint(const QString &tag) : + index_(-1), + tag_(tag) + { + } void Hash(QCryptographicHash &hash) const; void Load(QXmlStreamReader *reader); void Save(QXmlStreamWriter *writer) const; + + const QVector &types() const { return type_; } + const int &index() const { return index_; } + const QString& tag() const { return tag_; } + + void set_type(const QVector &type) { type_ = type; } + void set_index(const int &index) { index_ = index; } + void set_tag(const QString &tag) { tag_ = tag; } + + private: + QVector type_; + int index_; + QString tag_; + }; static void Hash(const Node *node, const ValueHint &hint, QCryptographicHash& hash, const NodeGlobals &globals, const VideoParams& video_params); diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 15e7e4b5d..347a9d717 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -106,18 +106,18 @@ NodeValue NodeTraverser::GenerateRowValueElement(const Node::ValueHint &hint, No int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table) { - QVector types = hint.type; + QVector types = hint.types(); if (types.isEmpty()) { types.append(preferred_type); } - if (hint.index == -1) { + if (hint.index() == -1) { // Get most recent value with this type and tag - return table->GetValueIndex(types, hint.tag); + return table->GetValueIndex(types, hint.tag()); } else { // Try to find value at this index - int index = table->Count() - 1 - hint.index; + int index = table->Count() - 1 - hint.index(); int diff = 0; while (index + diff < table->Count() && index - diff >= 0) { diff --git a/app/task/precache/precachetask.cpp b/app/task/precache/precachetask.cpp index e7aa6a9f0..033b64399 100644 --- a/app/task/precache/precachetask.cpp +++ b/app/task/precache/precachetask.cpp @@ -49,7 +49,7 @@ PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence* sequence) Node::CopyInputs(footage, footage_, false); Node::ConnectEdge(footage_, NodeInput(viewer(), ViewerOutput::kTextureInput)); - viewer()->SetValueHintForInput(ViewerOutput::kTextureInput, {{NodeValue::kTexture}, -1, Track::Reference(Track::kVideo, index).ToString()}); + viewer()->SetValueHintForInput(ViewerOutput::kTextureInput, Node::ValueHint({NodeValue::kTexture}, Track::Reference(Track::kVideo, index).ToString())); SetTitle(tr("Pre-caching %1:%2").arg(footage_->filename(), QString::number(index))); } diff --git a/app/widget/nodevaluetree/nodevaluetree.cpp b/app/widget/nodevaluetree/nodevaluetree.cpp index 28d938e22..74c18d4c0 100644 --- a/app/widget/nodevaluetree/nodevaluetree.cpp +++ b/app/widget/nodevaluetree/nodevaluetree.cpp @@ -38,7 +38,7 @@ void NodeValueTree::SetNode(const NodeInput &input, const rational &time) const NodeValue &value = table.at(i); QTreeWidgetItem *item = new QTreeWidgetItem(this); - Node::ValueHint hint = {{value.type()}, table.Count()-1-i, value.tag()}; + Node::ValueHint hint({value.type()}, table.Count()-1-i, value.tag()); QRadioButton *radio = new QRadioButton(this); radio->setProperty("input", QVariant::fromValue(input)); diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index 457dae3e2..5f379679f 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -405,7 +405,7 @@ void ImportTool::DropGhosts(bool insert) TransformDistortNode* transform = new TransformDistortNode(); command->add_child(new NodeAddCommand(dst_graph, transform)); - command->add_child(new NodeSetValueHintCommand(transform, TransformDistortNode::kTextureInput, -1, {{NodeValue::kTexture}, -1, footage_stream.output})); + command->add_child(new NodeSetValueHintCommand(transform, TransformDistortNode::kTextureInput, -1, Node::ValueHint({NodeValue::kTexture}, footage_stream.output))); command->add_child(new NodeEdgeAddCommand(footage_stream.footage, NodeInput(transform, TransformDistortNode::kTextureInput))); command->add_child(new NodeEdgeAddCommand(transform, NodeInput(clip, ClipBlock::kBufferIn))); @@ -417,7 +417,7 @@ void ImportTool::DropGhosts(bool insert) VolumeNode* volume_node = new VolumeNode(); command->add_child(new NodeAddCommand(dst_graph, volume_node)); - command->add_child(new NodeSetValueHintCommand(volume_node, VolumeNode::kSamplesInput, -1, {{NodeValue::kSamples}, -1, footage_stream.output})); + command->add_child(new NodeSetValueHintCommand(volume_node, VolumeNode::kSamplesInput, -1, Node::ValueHint({NodeValue::kSamples}, footage_stream.output))); command->add_child(new NodeEdgeAddCommand(footage_stream.footage, NodeInput(volume_node, VolumeNode::kSamplesInput))); command->add_child(new NodeEdgeAddCommand(volume_node, NodeInput(clip, ClipBlock::kBufferIn)));