render: reference-count graph snapshots to prevent premature deletion
Proxy generation modifies the project, causing graph snapshots to be rewritten. The old implementation deleted the previous snapshot immediately, even though queued render jobs still held its path. The worker then failed to load the deleted file. Add per-path reference counting: - Increment when a job is created with a snapshot path. - Decrement when the job is processed, cancelled or removed. - Only delete a snapshot when its reference count reaches zero and it is no longer the cached snapshot for the project. Also keep snapshots in the system temp directory as before, since the location itself was not the bug.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <QHash>
|
||||
#include <QMutex>
|
||||
#include <QSet>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <QWaitCondition>
|
||||
@@ -128,6 +129,12 @@ private:
|
||||
void FinishWithFrame(RenderTicketPtr ticket, const ipc::FrameSlotPool &pool,
|
||||
uint32_t slot);
|
||||
void CleanupGraphFile(const QString &path);
|
||||
void AddGraphPathRef(const QString &path);
|
||||
void AddGraphPathRefLocked(const QString &path);
|
||||
void ReleaseGraphPathRef(const QString &path);
|
||||
void ReleaseGraphPathRefLocked(const QString &path);
|
||||
void SetGraphPathCached(const QString &path, bool cached);
|
||||
void SetGraphPathCachedLocked(const QString &path, bool cached);
|
||||
void CancelActiveProcess(qint64 process_id);
|
||||
void SetActiveWorker(int worker_index, RenderTicketPtr ticket,
|
||||
QProcess *worker, qint64 ticket_id);
|
||||
@@ -151,6 +158,8 @@ private:
|
||||
bool stopping_ = false;
|
||||
QVector<ActiveJob> active_jobs_;
|
||||
QHash<QUuid, CachedGraph> graph_cache_;
|
||||
QHash<QString, int> graph_path_ref_count_;
|
||||
QSet<QString> cached_graph_paths_;
|
||||
|
||||
static constexpr uint32_t kOutputSlots = 2;
|
||||
static constexpr int kMaxAttempts = 2;
|
||||
|
||||
Reference in New Issue
Block a user