exporter: add ability to cancel exports (including a confirm to cancel if the
user closes the dialog mid-export)
This commit is contained in:
@@ -50,6 +50,24 @@ const QString &Exporter::GetExportError() const
|
||||
return export_msg_;
|
||||
}
|
||||
|
||||
void Exporter::Cancel()
|
||||
{
|
||||
if (video_backend_) {
|
||||
video_backend_->CancelQueue();
|
||||
video_backend_->deleteLater();
|
||||
video_backend_ = nullptr;
|
||||
}
|
||||
|
||||
if (audio_backend_) {
|
||||
audio_backend_->CancelQueue();
|
||||
audio_backend_->deleteLater();
|
||||
audio_backend_ = nullptr;
|
||||
}
|
||||
|
||||
SetExportMessage(tr("User cancelled export"));
|
||||
ExportStopped();
|
||||
}
|
||||
|
||||
void Exporter::StartExporting()
|
||||
{
|
||||
// Default to error state until ExportEnd is called
|
||||
@@ -101,6 +119,7 @@ void Exporter::ExportSucceeded()
|
||||
|
||||
if (video_backend_) {
|
||||
video_backend_->deleteLater();
|
||||
video_backend_ = nullptr;
|
||||
}
|
||||
|
||||
export_status_ = true;
|
||||
@@ -112,9 +131,10 @@ void Exporter::ExportSucceeded()
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void Exporter::ExportFailed()
|
||||
void Exporter::ExportStopped()
|
||||
{
|
||||
emit ExportEnded();
|
||||
encoder_->deleteLater();
|
||||
}
|
||||
|
||||
void Exporter::EncodeFrame()
|
||||
@@ -195,6 +215,7 @@ void Exporter::AudioRendered()
|
||||
|
||||
// We don't need the audio backend anymore
|
||||
audio_backend_->deleteLater();
|
||||
audio_backend_ = nullptr;
|
||||
}
|
||||
|
||||
void Exporter::AudioEncodeComplete()
|
||||
@@ -225,14 +246,14 @@ void Exporter::EncoderOpenedSuccessfully()
|
||||
|
||||
void Exporter::EncoderOpenFailed()
|
||||
{
|
||||
SetExportMessage("Failed to open encoder");
|
||||
ExportFailed();
|
||||
SetExportMessage(tr("Failed to open encoder"));
|
||||
ExportStopped();
|
||||
}
|
||||
|
||||
void Exporter::EncoderClosed()
|
||||
{
|
||||
emit ProgressChanged(100);
|
||||
emit ExportEnded();
|
||||
ExportStopped();
|
||||
}
|
||||
|
||||
void Exporter::VideoHashesComplete()
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
bool GetExportStatus() const;
|
||||
const QString& GetExportError() const;
|
||||
|
||||
void Cancel();
|
||||
|
||||
public slots:
|
||||
void StartExporting();
|
||||
|
||||
@@ -58,7 +60,7 @@ protected:
|
||||
private:
|
||||
void ExportSucceeded();
|
||||
|
||||
void ExportFailed();
|
||||
void ExportStopped();
|
||||
|
||||
void EncodeFrame();
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@ bool OpenGLBackend::InitInternal()
|
||||
if (!proxy_->Init()) {
|
||||
proxy_thread->quit();
|
||||
proxy_thread->wait();
|
||||
delete proxy_thread;
|
||||
delete proxy_;
|
||||
proxy_thread->deleteLater();
|
||||
|
||||
proxy_->deleteLater();
|
||||
proxy_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +56,11 @@ bool OpenGLBackend::InitInternal()
|
||||
void OpenGLBackend::CloseInternal()
|
||||
{
|
||||
if (proxy_) {
|
||||
delete proxy_;
|
||||
proxy_->thread()->quit();
|
||||
proxy_->thread()->wait();
|
||||
proxy_->thread()->deleteLater();
|
||||
|
||||
proxy_->deleteLater();
|
||||
proxy_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ OpenGLProxy::OpenGLProxy(QObject *parent) :
|
||||
|
||||
OpenGLProxy::~OpenGLProxy()
|
||||
{
|
||||
Close();
|
||||
|
||||
surface_.destroy();
|
||||
}
|
||||
|
||||
@@ -178,6 +180,7 @@ void OpenGLProxy::Close()
|
||||
buffer_.Destroy();
|
||||
functions_ = nullptr;
|
||||
delete ctx_;
|
||||
ctx_ = nullptr;
|
||||
}
|
||||
|
||||
void OpenGLProxy::RunNodeAccelerated(const Node *node, const TimeRange &range, const NodeValueDatabase &input_params, NodeValueTable *output_params)
|
||||
|
||||
@@ -326,7 +326,10 @@ void RenderBackend::CancelQueue()
|
||||
if (processor_busy_state_.at(i))
|
||||
busy++;
|
||||
}
|
||||
qDebug() << this << "is waiting for" << busy << "busy workers";
|
||||
|
||||
if (busy) {
|
||||
qDebug() << this << "is waiting for" << busy << "busy workers";
|
||||
}
|
||||
|
||||
cancel_dialog_->RunIfWorkersAreBusy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user