ensure invalidated values are removed
When a node receives an InvalidateCache signal, it will automatically signal its outputs to discard any cached values in the invalidated time range
This commit is contained in:
@@ -83,6 +83,13 @@ void Node::InvalidateCache(const rational &start_range, const rational &end_rang
|
||||
{
|
||||
Q_UNUSED(from)
|
||||
|
||||
foreach (NodeParam* param, params_) {
|
||||
if (param->type() == NodeParam::kOutput) {
|
||||
NodeOutput* output = static_cast<NodeOutput*>(param);
|
||||
output->drop_cached_values_overlapping(TimeRange(start_range, end_range));
|
||||
}
|
||||
}
|
||||
|
||||
SendInvalidateCache(start_range, end_range);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,3 +58,16 @@ void NodeOutput::drop_cached_values()
|
||||
{
|
||||
cached_values_.clear();
|
||||
}
|
||||
|
||||
void NodeOutput::drop_cached_values_overlapping(const TimeRange &time)
|
||||
{
|
||||
QHash<TimeRange, QVariant>::iterator i = cached_values_.begin();
|
||||
|
||||
while (i != cached_values_.end()) {
|
||||
if (i.key().OverlapsWith(time)) {
|
||||
i = cached_values_.erase(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
QVariant get_cached_value(const TimeRange& time);
|
||||
void cache_value(const TimeRange& time, const QVariant& value);
|
||||
void drop_cached_values();
|
||||
void drop_cached_values_overlapping(const TimeRange& time);
|
||||
|
||||
private:
|
||||
QHash<TimeRange, QVariant> cached_values_;
|
||||
|
||||
Reference in New Issue
Block a user