disambiguated whether NodeParam::parent() would return a Node* or a QObject*
Old code assumes that a NodeParam's parent will always be a Node. The function has been separated off and tweaked in the event that this is not the case.
This commit is contained in:
+9
-9
@@ -73,7 +73,7 @@ Node *NodeInput::get_connected_node()
|
||||
NodeOutput* output = get_connected_output();
|
||||
|
||||
if (output != nullptr) {
|
||||
return output->parent();
|
||||
return output->parentNode();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -129,8 +129,8 @@ QVariant NodeInput::get_value_at_time(const rational &time)
|
||||
|
||||
void NodeInput::set_value_at_time(const rational &time, const QVariant &value)
|
||||
{
|
||||
if (parent() != nullptr)
|
||||
parent()->LockUserInput();
|
||||
if (parentNode() != nullptr)
|
||||
parentNode()->LockUserInput();
|
||||
|
||||
// We set up these variables in advance (see end of function)
|
||||
bool signal_vc = false;
|
||||
@@ -216,8 +216,8 @@ void NodeInput::set_value_at_time(const rational &time, const QVariant &value)
|
||||
signal_vc_range = TimeRange(RATIONAL_MIN, RATIONAL_MAX);
|
||||
}
|
||||
|
||||
if (parent() != nullptr)
|
||||
parent()->UnlockUserInput();
|
||||
if (parentNode() != nullptr)
|
||||
parentNode()->UnlockUserInput();
|
||||
|
||||
// We make sure this signal is emitted AFTER we've unlocked the node in case this leads to a tangent where something
|
||||
// tries to relock this node before it's unlocked here
|
||||
@@ -298,8 +298,8 @@ void NodeInput::set_maximum(const QVariant &max)
|
||||
|
||||
void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_connections)
|
||||
{
|
||||
source->parent()->LockUserInput();
|
||||
dest->parent()->LockUserInput();
|
||||
source->parentNode()->LockUserInput();
|
||||
dest->parentNode()->LockUserInput();
|
||||
|
||||
// Copy values
|
||||
dest->keyframes_ = source->keyframes_;
|
||||
@@ -307,8 +307,8 @@ void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_conn
|
||||
// Copy keyframing state
|
||||
dest->set_is_keyframing(source->is_keyframing());
|
||||
|
||||
source->parent()->UnlockUserInput();
|
||||
dest->parent()->UnlockUserInput();
|
||||
source->parentNode()->UnlockUserInput();
|
||||
dest->parentNode()->UnlockUserInput();
|
||||
|
||||
// Copy connections
|
||||
if (include_connections && source->get_connected_output() != nullptr) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "inputarray.h"
|
||||
|
||||
InputArray::InputArray()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef INPUTARRAY_H
|
||||
#define INPUTARRAY_H
|
||||
|
||||
|
||||
class InputArray
|
||||
{
|
||||
public:
|
||||
InputArray();
|
||||
};
|
||||
|
||||
#endif // INPUTARRAY_H
|
||||
+5
-5
@@ -106,7 +106,7 @@ void Node::SendInvalidateCache(const rational &start_range, const rational &end_
|
||||
|
||||
foreach (NodeEdgePtr edge, edges) {
|
||||
NodeInput* connected_input = edge->input();
|
||||
Node* connected_node = connected_input->parent();
|
||||
Node* connected_node = connected_input->parentNode();
|
||||
|
||||
// Send clear cache signal to the Node
|
||||
connected_node->InvalidateCache(start_range, end_range, connected_input);
|
||||
@@ -125,7 +125,7 @@ void Node::DependentEdgeChanged(NodeInput *from)
|
||||
|
||||
foreach (NodeEdgePtr edge, out->edges()) {
|
||||
NodeInput* connected_input = edge->input();
|
||||
Node* connected_node = connected_input->parent();
|
||||
Node* connected_node = connected_input->parentNode();
|
||||
|
||||
connected_node->DependentEdgeChanged(connected_input);
|
||||
}
|
||||
@@ -204,14 +204,14 @@ void Node::DuplicateConnectionsBetweenLists(const QList<Node *> &source, const Q
|
||||
|
||||
// Get this input's connected outputs
|
||||
NodeOutput* source_output = source_input->get_connected_output();
|
||||
Node* source_output_node = source_output->parent();
|
||||
Node* source_output_node = source_output->parentNode();
|
||||
|
||||
// Find equivalent in destination list
|
||||
Node* dest_output_node = destination.at(source.indexOf(source_output_node));
|
||||
|
||||
Q_ASSERT(dest_output_node->id() == source_output_node->id());
|
||||
|
||||
NodeOutput* dest_output = static_cast<NodeOutput*>(dest_output_node->params_.at(source_output->index()));
|
||||
NodeOutput* dest_output = static_cast<NodeOutput*>(dest_output_node->GetParameterWithID(source_output->id()));
|
||||
|
||||
NodeParam::ConnectEdge(dest_output, dest_input);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ QList<Node *> Node::GetExclusiveDependencies()
|
||||
|
||||
// If any edge goes to from an output here to an input of a Node that isn't in this dep list, it's NOT an
|
||||
// exclusive dependency
|
||||
if (deps.contains(edge->input()->parent())) {
|
||||
if (deps.contains(edge->input()->parentNode())) {
|
||||
deps.removeAt(i);
|
||||
|
||||
i--; // -1 since we just removed a Node in this list
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ NodeParam::Type NodeOutput::type()
|
||||
|
||||
QVariant NodeOutput::get_realtime_value()
|
||||
{
|
||||
QVariant v = parent()->Value(this);
|
||||
QVariant v = parentNode()->Value(this);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
+25
-13
@@ -56,14 +56,26 @@ void NodeParam::set_name(const QString &name)
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
Node *NodeParam::parent()
|
||||
Node *NodeParam::parentNode()
|
||||
{
|
||||
return static_cast<Node*>(QObject::parent());
|
||||
QObject* p = parent();
|
||||
|
||||
while (p != nullptr) {
|
||||
// Determine if this object is a Node or not
|
||||
Node* cast_test = dynamic_cast<Node*>(p);
|
||||
if (cast_test != nullptr) {
|
||||
return cast_test;
|
||||
}
|
||||
|
||||
p = p->parent();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int NodeParam::index()
|
||||
{
|
||||
return parent()->IndexOfParameter(this);
|
||||
return parentNode()->IndexOfParameter(this);
|
||||
}
|
||||
|
||||
bool NodeParam::IsConnected()
|
||||
@@ -96,7 +108,7 @@ NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input)
|
||||
}
|
||||
|
||||
// Ensure both nodes are in the same graph
|
||||
if (output->parent()->parent() != input->parent()->parent()) {
|
||||
if (output->parentNode()->parent() != input->parentNode()->parent()) {
|
||||
qWarning() << "Tried to connect two nodes that aren't part of the same graph";
|
||||
return nullptr;
|
||||
}
|
||||
@@ -105,16 +117,16 @@ NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input)
|
||||
|
||||
// The nodes should never be the same, and since we lock both nodes here, this can lead to a entire program freeze
|
||||
// that's difficult to diagnose. This makes that issue very clear.
|
||||
Q_ASSERT(output->parent() != input->parent());
|
||||
Q_ASSERT(output->parentNode() != input->parentNode());
|
||||
|
||||
output->parent()->LockUserInput();
|
||||
input->parent()->LockUserInput();
|
||||
output->parentNode()->LockUserInput();
|
||||
input->parentNode()->LockUserInput();
|
||||
|
||||
output->edges_.append(edge);
|
||||
input->edges_.append(edge);
|
||||
|
||||
output->parent()->UnlockUserInput();
|
||||
input->parent()->UnlockUserInput();
|
||||
output->parentNode()->UnlockUserInput();
|
||||
input->parentNode()->UnlockUserInput();
|
||||
|
||||
// Emit a signal than an edge was added (only one signal needs emitting)
|
||||
emit input->EdgeAdded(edge);
|
||||
@@ -127,14 +139,14 @@ void NodeParam::DisconnectEdge(NodeEdgePtr edge)
|
||||
NodeOutput* output = edge->output();
|
||||
NodeInput* input = edge->input();
|
||||
|
||||
output->parent()->LockUserInput();
|
||||
input->parent()->LockUserInput();
|
||||
output->parentNode()->LockUserInput();
|
||||
input->parentNode()->LockUserInput();
|
||||
|
||||
output->edges_.removeOne(edge);
|
||||
input->edges_.removeOne(edge);
|
||||
|
||||
output->parent()->UnlockUserInput();
|
||||
input->parent()->UnlockUserInput();
|
||||
output->parentNode()->UnlockUserInput();
|
||||
input->parentNode()->UnlockUserInput();
|
||||
|
||||
emit input->EdgeRemoved(edge);
|
||||
}
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public:
|
||||
* Nodes and NodeParams use the QObject parent-child system. This function is a convenience function for
|
||||
* static_cast<Node*>(QObject::parent())
|
||||
*/
|
||||
Node* parent();
|
||||
Node* parentNode();
|
||||
|
||||
/**
|
||||
* @brief Return the row index of this parameter in the parent node (primarily used for UI drawing functions)
|
||||
|
||||
@@ -15,7 +15,7 @@ void AudioRenderWorker::SetParameters(const AudioRenderingParams &audio_params)
|
||||
QVariant AudioRenderWorker::RenderAsSibling(NodeDependency dep)
|
||||
{
|
||||
NodeOutput* output = dep.node();
|
||||
Node* node = output->parent();
|
||||
Node* node = output->parentNode();
|
||||
QList<NodeInput*> connected_inputs;
|
||||
QVariant value;
|
||||
|
||||
@@ -66,7 +66,7 @@ void AudioRenderWorker::CloseInternal()
|
||||
|
||||
QVariant AudioRenderWorker::RenderBlock(NodeOutput* output, const TimeRange &range)
|
||||
{
|
||||
QList<Block*> active_blocks = ValidateBlockRange(static_cast<Block*>(output->parent()), range);
|
||||
QList<Block*> active_blocks = ValidateBlockRange(static_cast<Block*>(output->parentNode()), range);
|
||||
|
||||
// All these blocks will need to output to a buffer so we create one here
|
||||
QByteArray block_range_buffer(audio_params_.time_to_bytes(range.length()), 0);
|
||||
|
||||
@@ -88,7 +88,7 @@ bool OpenGLBackend::TraverseCompiling(Node *n)
|
||||
// Check if we have a shader or not
|
||||
if (shader_cache_.GetShader(connected_output) == nullptr) {
|
||||
// Since we don't have a shader, compile one now
|
||||
QString node_code = connected_output->parent()->Code(connected_output);
|
||||
QString node_code = connected_output->parentNode()->Code(connected_output);
|
||||
|
||||
// If the node has no code, it mustn't be GPU accelerated
|
||||
if (!node_code.isEmpty()) {
|
||||
@@ -126,7 +126,7 @@ bool OpenGLBackend::TraverseCompiling(Node *n)
|
||||
}
|
||||
}
|
||||
|
||||
if (!TraverseCompiling(connected_output->parent())) {
|
||||
if (!TraverseCompiling(connected_output->parentNode())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ OpenGLShaderCache::OpenGLShaderCache()
|
||||
QString OpenGLShaderCache::GenerateShaderID(NodeOutput *output)
|
||||
{
|
||||
// Creates a unique identifier for this specific node and this specific output
|
||||
return QString("%1:%2").arg(output->parent()->id(), output->id());
|
||||
return QString("%1:%2").arg(output->parentNode()->id(), output->id());
|
||||
}
|
||||
|
||||
void OpenGLShaderCache::Clear()
|
||||
|
||||
@@ -86,7 +86,7 @@ void OpenGLWorker::ParametersChangedEvent()
|
||||
QVariant OpenGLWorker::RunNodeAccelerated(NodeOutput *out)
|
||||
{
|
||||
OpenGLShaderPtr shader = shader_cache_->GetShader(out);
|
||||
Node* node = out->parent();
|
||||
Node* node = out->parentNode();
|
||||
|
||||
// Create the output texture
|
||||
OpenGLTexturePtr output = std::make_shared<OpenGLTexture>();
|
||||
|
||||
@@ -171,7 +171,7 @@ QList<NodeInput*> RenderWorker::ProcessNodeInputsForTime(Node *n, const TimeRang
|
||||
QVariant RenderWorker::ProcessNodeNormally(const NodeDependency& dep)
|
||||
{
|
||||
NodeOutput* output = dep.node();
|
||||
Node* node = dep.node()->parent();
|
||||
Node* node = dep.node()->parentNode();
|
||||
|
||||
//qDebug() << "Processing" << node->id();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ void VideoRenderWorker::RenderInternal(const NodeDependency& path)
|
||||
// Get hash of node graph
|
||||
// We use SHA-1 for speed (benchmarks show it's the fastest hash available to us)
|
||||
QCryptographicHash hasher(QCryptographicHash::Sha1);
|
||||
HashNodeRecursively(&hasher, path.node()->parent(), path.in());
|
||||
HashNodeRecursively(&hasher, path.node()->parentNode(), path.in());
|
||||
QByteArray hash = hasher.result();
|
||||
|
||||
if (frame_cache_->HasHash(hash)) {
|
||||
@@ -123,7 +123,7 @@ void VideoRenderWorker::CloseInternal()
|
||||
QVariant VideoRenderWorker::RenderAsSibling(NodeDependency dep)
|
||||
{
|
||||
NodeOutput* output = dep.node();
|
||||
Node* original_node = output->parent();
|
||||
Node* original_node = output->parentNode();
|
||||
Node* node;
|
||||
rational time = dep.in();
|
||||
QVariant value;
|
||||
|
||||
@@ -80,8 +80,8 @@ void NodeViewEdge::Adjust()
|
||||
}
|
||||
|
||||
// Get the UI objects of both nodes that this edge connects
|
||||
NodeViewItem* output = NodeView::NodeToUIObject(scene(), edge_->output()->parent());
|
||||
NodeViewItem* input = NodeView::NodeToUIObject(scene(), edge_->input()->parent());
|
||||
NodeViewItem* output = NodeView::NodeToUIObject(scene(), edge_->output()->parentNode());
|
||||
NodeViewItem* input = NodeView::NodeToUIObject(scene(), edge_->input()->parentNode());
|
||||
|
||||
// Create initial values
|
||||
QPointF output_point = QPointF(output->pos().x() + output->rect().width(), 0);
|
||||
|
||||
@@ -304,7 +304,7 @@ void NodeViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
drag_src_param_ = edge->output();
|
||||
|
||||
// Get its Node UI object
|
||||
drag_source_ = NodeView::NodeToUIObject(scene(), drag_src_param_->parent());
|
||||
drag_source_ = NodeView::NodeToUIObject(scene(), drag_src_param_->parentNode());
|
||||
|
||||
// Get the opposing parameter's rect center using the line's current coordinates
|
||||
// (we use the current coordinates because a complex formula is used for the line's coords if the opposing
|
||||
@@ -387,11 +387,11 @@ void NodeViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
// Determine which Node will be "submitting output" and which node will be "receiving input"
|
||||
if (drag_src_param_->type() == NodeParam::kInput) {
|
||||
receiving_node = drag_src_param_->parent();
|
||||
receiving_node = drag_src_param_->parentNode();
|
||||
outputting_node = drop_item->node();
|
||||
} else {
|
||||
receiving_node = drop_item->node();
|
||||
outputting_node = drag_src_param_->parent();
|
||||
outputting_node = drag_src_param_->parentNode();
|
||||
}
|
||||
|
||||
// Ensure the receiving node doesn't output to the outputting node
|
||||
|
||||
Reference in New Issue
Block a user