track: fixed issues from recent rework
This commit is contained in:
@@ -36,8 +36,7 @@ const QString Block::kLengthInput = QStringLiteral("length_in");
|
||||
Block::Block() :
|
||||
previous_(nullptr),
|
||||
next_(nullptr),
|
||||
track_(nullptr),
|
||||
index_(-1)
|
||||
track_(nullptr)
|
||||
{
|
||||
AddInput(kLengthInput, NodeValue::kRational, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagHidden));
|
||||
SetInputProperty(kLengthInput, QStringLiteral("min"), QVariant::fromValue(rational(0, 1)));
|
||||
|
||||
@@ -104,16 +104,6 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
int index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
void set_index(int i)
|
||||
{
|
||||
index_ = i;
|
||||
}
|
||||
|
||||
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()) override;
|
||||
|
||||
static const QString kLengthInput;
|
||||
@@ -143,7 +133,6 @@ private:
|
||||
rational in_point_;
|
||||
rational out_point_;
|
||||
Track* track_;
|
||||
int index_;
|
||||
|
||||
rational last_length_;
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ Track::Track() :
|
||||
locked_(false),
|
||||
sequence_(nullptr),
|
||||
ignore_arraymap_(0),
|
||||
arraymap_invalid_(false)
|
||||
arraymap_invalid_(false),
|
||||
ignore_arraymap_set_(false)
|
||||
{
|
||||
AddInput(kBlockInput, NodeValue::kNone, InputFlags(kInputFlagArray | kInputFlagNotKeyframable | kInputFlagHidden | kInputFlagIgnoreInvalidations));
|
||||
|
||||
@@ -197,6 +198,8 @@ void Track::SetTrackHeight(const double &height)
|
||||
|
||||
bool Track::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
{
|
||||
ignore_arraymap_set_ = true;
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
if (reader->name() == QStringLiteral("height")) {
|
||||
this->SetTrackHeight(reader->readElementText().toDouble());
|
||||
@@ -213,6 +216,12 @@ void Track::SaveCustom(QXmlStreamWriter *writer) const
|
||||
writer->writeTextElement(QStringLiteral("height"), QString::number(this->GetTrackHeight()));
|
||||
}
|
||||
|
||||
void Track::PostLoadEvent(SerializedData *data)
|
||||
{
|
||||
ignore_arraymap_set_ = false;
|
||||
RefreshBlockCacheFromArrayMap();
|
||||
}
|
||||
|
||||
void Track::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
@@ -457,6 +466,8 @@ void Track::RippleRemoveBlock(Block *block)
|
||||
Block::set_previous_next(previous, next);
|
||||
block->set_previous(nullptr);
|
||||
block->set_next(nullptr);
|
||||
block->set_in(0);
|
||||
block->set_out(block->length());
|
||||
|
||||
// Update in/outs
|
||||
UpdateInOutFrom(index);
|
||||
@@ -563,8 +574,6 @@ void Track::UpdateInOutFrom(int index)
|
||||
last_out += b->length();
|
||||
|
||||
b->set_out(last_out);
|
||||
|
||||
b->set_index(i);
|
||||
}
|
||||
|
||||
emit BlocksRefreshed();
|
||||
@@ -731,6 +740,21 @@ void Track::UpdateArrayMap()
|
||||
|
||||
void Track::RefreshBlockCacheFromArrayMap()
|
||||
{
|
||||
if (ignore_arraymap_set_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disconnecting any existing blocks
|
||||
for (Block *b : blocks_) {
|
||||
Q_ASSERT(b->track() == this);
|
||||
b->set_track(nullptr);
|
||||
b->set_previous(nullptr);
|
||||
b->set_next(nullptr);
|
||||
b->set_in(0);
|
||||
b->set_out(b->length());
|
||||
disconnect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
}
|
||||
|
||||
QByteArray bytes = GetStandardValue(kArrayMapInput).toByteArray();
|
||||
block_array_indexes_.resize(bytes.size() / sizeof(uint32_t));
|
||||
memcpy(block_array_indexes_.data(), bytes.data(), bytes.size());
|
||||
@@ -747,6 +771,8 @@ void Track::RefreshBlockCacheFromArrayMap()
|
||||
|
||||
if (b) {
|
||||
b->set_track(this);
|
||||
connect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
|
||||
blocks_.append(b);
|
||||
prev = b;
|
||||
} else {
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
|
||||
virtual bool LoadCustom(QXmlStreamReader *reader, SerializedData *data) override;
|
||||
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
|
||||
virtual void PostLoadEvent(SerializedData *data);
|
||||
|
||||
static int InternalHeightToPixelHeight(double h)
|
||||
{
|
||||
@@ -484,6 +485,7 @@ private:
|
||||
|
||||
int ignore_arraymap_;
|
||||
bool arraymap_invalid_;
|
||||
bool ignore_arraymap_set_;
|
||||
|
||||
private slots:
|
||||
void BlockLengthChanged();
|
||||
|
||||
@@ -291,8 +291,6 @@ ProjectSerializer230220::LoadData ProjectSerializer230220::Load(Project *project
|
||||
}
|
||||
}
|
||||
|
||||
PostConnect(load_data.nodes, &project_data);
|
||||
|
||||
// Resolve serialized properties (if any)
|
||||
for (auto it=properties.cbegin(); it!=properties.cend(); it++) {
|
||||
Node *node = project_data.node_ptrs.value(it.key());
|
||||
@@ -300,6 +298,8 @@ ProjectSerializer230220::LoadData ProjectSerializer230220::Load(Project *project
|
||||
load_data.properties.insert(node, it.value());
|
||||
}
|
||||
}
|
||||
|
||||
PostConnect(load_data.nodes, &project_data);
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -452,14 +452,6 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, const SaveData &dat
|
||||
|
||||
void ProjectSerializer230220::PostConnect(const QVector<Node *> &nodes, SerializedData *project_data) const
|
||||
{
|
||||
for (auto it = nodes.cbegin(); it != nodes.cend(); it++){
|
||||
Node *n = *it;
|
||||
|
||||
n->PostLoadEvent(project_data);
|
||||
|
||||
n->SetCachesEnabled(true);
|
||||
}
|
||||
|
||||
foreach (const SerializedData::SerializedConnection& con, project_data->desired_connections) {
|
||||
if (Node *out = project_data->node_ptrs.value(con.output_node)) {
|
||||
Node::ConnectEdge(out, con.input);
|
||||
@@ -472,6 +464,14 @@ void ProjectSerializer230220::PostConnect(const QVector<Node *> &nodes, Serializ
|
||||
|
||||
Node::Link(a, b);
|
||||
}
|
||||
|
||||
for (auto it = nodes.cbegin(); it != nodes.cend(); it++){
|
||||
Node *n = *it;
|
||||
|
||||
n->PostLoadEvent(project_data);
|
||||
|
||||
n->SetCachesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -251,13 +251,13 @@ void ProjectCopier::QueueEdgeRemove(Node *output, const NodeInput &input)
|
||||
|
||||
void ProjectCopier::QueueValueChange(const NodeInput &input)
|
||||
{
|
||||
for (auto it = graph_update_queue_.begin(); it != graph_update_queue_.end(); ) {
|
||||
/*for (auto it = graph_update_queue_.begin(); it != graph_update_queue_.end(); ) {
|
||||
if (it->type == QueuedJob::kValueChanged && it->input == input) {
|
||||
it = graph_update_queue_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
graph_update_queue_.push_back({QueuedJob::kValueChanged, nullptr, input, nullptr, QString(), QString()});
|
||||
UpdateGraphChangeValue();
|
||||
|
||||
Reference in New Issue
Block a user