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)
|
||||
|
||||
Reference in New Issue
Block a user