node: improved input error reporting

This commit is contained in:
itsmattkc
2022-10-02 11:00:14 -07:00
parent ecb901ea9a
commit 2f9ec9d13e
2 changed files with 37 additions and 40 deletions
+36 -39
View File
@@ -27,11 +27,8 @@
#include "common/bezier.h"
#include "common/lerp.h"
#include "common/timecodefunctions.h"
#include "common/xmlutils.h"
#include "core.h"
#include "config/config.h"
#include "node/project/footage/footage.h"
#include "project/project.h"
#include "ui/colorcoding.h"
#include "ui/icons/icons.h"
@@ -251,7 +248,7 @@ QString Node::GetInputName(const QString &id) const
if (i) {
return i->human_name;
} else {
ReportInvalidInput("get name of", id);
ReportInvalidInput("get name of", id, -1);
return QString();
}
}
@@ -278,7 +275,7 @@ bool Node::IsInputKeyframing(const QString &input, int element) const
if (imm) {
return imm->is_keyframing();
} else {
ReportInvalidInput("get keyframing state of", input);
ReportInvalidInput("get keyframing state of", input, element);
return false;
}
}
@@ -297,7 +294,7 @@ void Node::SetInputIsKeyframing(const QString &input, bool e, int element)
emit KeyframeEnableChanged(NodeInput(this, input, element), e);
} else {
ReportInvalidInput("set keyframing state of", input);
ReportInvalidInput("set keyframing state of", input, element);
}
}
@@ -324,7 +321,7 @@ bool Node::IsUsingStandardValue(const QString &input, int track, int element) co
if (imm) {
return imm->is_using_standard_value(track);
} else {
ReportInvalidInput("determine whether using standard value in", input);
ReportInvalidInput("determine whether using standard value in", input, element);
return true;
}
}
@@ -336,7 +333,7 @@ NodeValue::Type Node::GetInputDataType(const QString &id) const
if (i) {
return i->type;
} else {
ReportInvalidInput("get data type of", id);
ReportInvalidInput("get data type of", id, -1);
return NodeValue::kNone;
}
}
@@ -355,7 +352,7 @@ void Node::SetInputDataType(const QString &id, const NodeValue::Type &type)
emit InputDataTypeChanged(id, type);
} else {
ReportInvalidInput("set data type of", id);
ReportInvalidInput("set data type of", id, -1);
}
}
@@ -366,7 +363,7 @@ bool Node::HasInputProperty(const QString &id, const QString &name) const
if (i) {
return i->properties.contains(name);
} else {
ReportInvalidInput("get property of", id);
ReportInvalidInput("get property of", id, -1);
return false;
}
}
@@ -378,7 +375,7 @@ QHash<QString, QVariant> Node::GetInputProperties(const QString &id) const
if (i) {
return i->properties;
} else {
ReportInvalidInput("get property table of", id);
ReportInvalidInput("get property table of", id, -1);
return QHash<QString, QVariant>();
}
}
@@ -390,7 +387,7 @@ QVariant Node::GetInputProperty(const QString &id, const QString &name) const
if (i) {
return i->properties.value(name);
} else {
ReportInvalidInput("get property of", id);
ReportInvalidInput("get property of", id, -1);
return QVariant();
}
}
@@ -404,7 +401,7 @@ void Node::SetInputProperty(const QString &id, const QString &name, const QVaria
emit InputPropertyChanged(id, name, value);
} else {
ReportInvalidInput("set property of", id);
ReportInvalidInput("set property of", id, -1);
}
}
@@ -548,7 +545,7 @@ SplitValue Node::GetSplitDefaultValue(const QString &input) const
if (i) {
return i->default_value;
} else {
ReportInvalidInput("retrieve default value of", input);
ReportInvalidInput("retrieve default value of", input, -1);
return SplitValue();
}
}
@@ -577,7 +574,7 @@ void Node::SetSplitDefaultValue(const QString &input, const SplitValue &val)
if (i) {
i->default_value = val;
} else {
ReportInvalidInput("set default value of", input);
ReportInvalidInput("set default value of", input, -1);
}
}
@@ -590,7 +587,7 @@ void Node::SetSplitDefaultValueOnTrack(const QString &input, const QVariant &val
i->default_value[track] = val;
}
} else {
ReportInvalidInput("set default value on track of", input);
ReportInvalidInput("set default value on track of", input, -1);
}
}
@@ -606,7 +603,7 @@ QVector<NodeKeyframe *> Node::GetKeyframesAtTime(const QString &input, const rat
if (imm) {
return imm->get_keyframe_at_time(time);
} else {
ReportInvalidInput("get keyframes at time from", input);
ReportInvalidInput("get keyframes at time from", input, element);
return QVector<NodeKeyframe*>();
}
}
@@ -618,7 +615,7 @@ NodeKeyframe *Node::GetKeyframeAtTimeOnTrack(const QString &input, const rationa
if (imm) {
return imm->get_keyframe_at_time_on_track(time, track);
} else {
ReportInvalidInput("get keyframe at time on track from", input);
ReportInvalidInput("get keyframe at time on track from", input, element);
return nullptr;
}
}
@@ -630,7 +627,7 @@ NodeKeyframe::Type Node::GetBestKeyframeTypeForTimeOnTrack(const QString &input,
if (imm) {
return imm->get_best_keyframe_type_for_time(time, track);
} else {
ReportInvalidInput("get closest keyframe before a time from", input);
ReportInvalidInput("get closest keyframe before a time from", input, element);
return NodeKeyframe::kDefaultType;
}
}
@@ -647,7 +644,7 @@ NodeKeyframe *Node::GetEarliestKeyframe(const QString &id, int element) const
if (imm) {
return imm->get_earliest_keyframe();
} else {
ReportInvalidInput("get earliest keyframe from", id);
ReportInvalidInput("get earliest keyframe from", id, element);
return nullptr;
}
}
@@ -659,7 +656,7 @@ NodeKeyframe *Node::GetLatestKeyframe(const QString &id, int element) const
if (imm) {
return imm->get_latest_keyframe();
} else {
ReportInvalidInput("get latest keyframe from", id);
ReportInvalidInput("get latest keyframe from", id, element);
return nullptr;
}
}
@@ -671,7 +668,7 @@ NodeKeyframe *Node::GetClosestKeyframeBeforeTime(const QString &id, const ration
if (imm) {
return imm->get_closest_keyframe_before_time(time);
} else {
ReportInvalidInput("get closest keyframe before a time from", id);
ReportInvalidInput("get closest keyframe before a time from", id, element);
return nullptr;
}
}
@@ -683,7 +680,7 @@ NodeKeyframe *Node::GetClosestKeyframeAfterTime(const QString &id, const rationa
if (imm) {
return imm->get_closest_keyframe_after_time(time);
} else {
ReportInvalidInput("get closest keyframe after a time from", id);
ReportInvalidInput("get closest keyframe after a time from", id, element);
return nullptr;
}
}
@@ -695,7 +692,7 @@ bool Node::HasKeyframeAtTime(const QString &id, const rational &time, int elemen
if (imm) {
return imm->has_keyframe_at_time(time);
} else {
ReportInvalidInput("determine if it has a keyframe at a time from", id);
ReportInvalidInput("determine if it has a keyframe at a time from", id, element);
return false;
}
}
@@ -719,7 +716,7 @@ SplitValue Node::GetSplitStandardValue(const QString &id, int element) const
if (imm) {
return imm->get_split_standard_value();
} else {
ReportInvalidInput("get standard value of", id);
ReportInvalidInput("get standard value of", id, element);
return SplitValue();
}
}
@@ -731,7 +728,7 @@ QVariant Node::GetSplitStandardValueOnTrack(const QString &input, int track, int
if (imm) {
return imm->get_split_standard_value_on_track(track);
} else {
ReportInvalidInput("get standard value of", input);
ReportInvalidInput("get standard value of", input, element);
return QVariant();
}
}
@@ -758,7 +755,7 @@ void Node::SetSplitStandardValue(const QString &id, const SplitValue &value, int
}
}
} else {
ReportInvalidInput("set standard value of", id);
ReportInvalidInput("set standard value of", id, element);
}
}
@@ -774,7 +771,7 @@ void Node::SetSplitStandardValueOnTrack(const QString &id, int track, const QVar
ParameterValueChanged(id, element, TimeRange(RATIONAL_MIN, RATIONAL_MAX));
}
} else {
ReportInvalidInput("set standard value of", id);
ReportInvalidInput("set standard value of", id, element);
}
}
@@ -873,7 +870,7 @@ int Node::InputArraySize(const QString &id) const
if (i) {
return i->array_size;
} else {
ReportInvalidInput("retrieve array size of", id);
ReportInvalidInput("retrieve array size of", id, -1);
return 0;
}
}
@@ -914,7 +911,7 @@ InputFlags Node::GetInputFlags(const QString &input) const
if (i) {
return i->flags;
} else {
ReportInvalidInput("retrieve flags of", input);
ReportInvalidInput("retrieve flags of", input, -1);
return InputFlags(kInputFlagNormal);
}
}
@@ -927,7 +924,7 @@ void Node::SetInputFlags(const QString &input, const InputFlags &f)
i->flags = f;
emit InputFlagsChanged(input, i->flags);
} else {
ReportInvalidInput("set flags of", input);
ReportInvalidInput("set flags of", input, -1);
}
}
@@ -1227,7 +1224,7 @@ void Node::RemoveInput(const QString &id)
int index = input_ids_.indexOf(id);
if (index == -1) {
ReportInvalidInput("remove", id);
ReportInvalidInput("remove", id, -1);
return;
}
@@ -1237,9 +1234,9 @@ void Node::RemoveInput(const QString &id)
emit InputRemoved(id);
}
void Node::ReportInvalidInput(const char *attempted_action, const QString& id) const
void Node::ReportInvalidInput(const char *attempted_action, const QString& id, int element) const
{
qWarning() << "Failed to" << attempted_action << "parameter" << id
qWarning() << "Failed to" << attempted_action << "parameter" << id << "element" << element
<< "in node" << this->id() << "- input doesn't exist";
}
@@ -1250,7 +1247,7 @@ NodeInputImmediate *Node::CreateImmediate(const QString &input)
if (i) {
return new NodeInputImmediate(i->type, i->default_value);
} else {
ReportInvalidInput("create immediate", input);
ReportInvalidInput("create immediate", input, -1);
return nullptr;
}
}
@@ -1260,7 +1257,7 @@ void Node::ArrayResizeInternal(const QString &id, int size)
Input* imm = GetInternalInputData(id);
if (!imm) {
ReportInvalidInput("set array size", id);
ReportInvalidInput("set array size", id, -1);
return;
}
@@ -1299,7 +1296,7 @@ void Node::SetInputName(const QString &id, const QString &name)
emit InputNameChanged(id, name);
} else {
ReportInvalidInput("set name of", id);
ReportInvalidInput("set name of", id, -1);
}
}
@@ -1426,8 +1423,8 @@ void Node::CopyValuesOfElement(const Node *src, Node *dst, const QString &input,
}
}
foreach (const NodeKeyframeTrack& track, src->GetImmediate(input, src_element)->keyframe_tracks()) {
foreach (NodeKeyframe* key, track) {
for (const NodeKeyframeTrack& track : src->GetImmediate(input, src_element)->keyframe_tracks()) {
for (NodeKeyframe* key : track) {
NodeKeyframe *copy = key->copy(dst_element, command ? nullptr : dst);
if (command) {
command->add_child(new NodeParamInsertKeyframeCommand(dst, copy));
+1 -1
View File
@@ -1352,7 +1352,7 @@ private:
}
}
void ReportInvalidInput(const char* attempted_action, const QString &id) const;
void ReportInvalidInput(const char* attempted_action, const QString &id, int element) const;
void ArrayResizeInternal(const QString& id, int size);