The workers run in separate threads meaning if any significant change is made (e.g. parameters changing, or even closing the program), these workers may still be mid-render. This is particularly problematic when closing since the nodes a worker is rendering may be deleted mid-render. Render backends now have a function that pauses the main thread (but starts a second event loop so the UI isn't frozen) until the worker threads are all finished. This way, massive changes can be made safely without race conditions.
36 lines
551 B
C++
36 lines
551 B
C++
#ifndef RENDERCANCELDIALOG_H
|
|
#define RENDERCANCELDIALOG_H
|
|
|
|
#include "dialog/loadsave/loadsave.h"
|
|
|
|
class RenderCancelDialog : public LoadSaveDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
RenderCancelDialog(QWidget* parent = nullptr);
|
|
|
|
void RunIfWorkersAreBusy();
|
|
|
|
void SetWorkerCount(int count);
|
|
|
|
void WorkerStarted();
|
|
|
|
public slots:
|
|
void WorkerDone();
|
|
|
|
protected:
|
|
virtual void showEvent(QShowEvent* event) override;
|
|
|
|
private:
|
|
void UpdateProgress();
|
|
|
|
int busy_workers_;
|
|
|
|
int total_workers_;
|
|
|
|
int waiting_workers_;
|
|
|
|
};
|
|
|
|
#endif // RENDERCANCELDIALOG_H
|