Fix crash when closing export dialog while export is running
TaskDialog::closeEvent() was calling deleteLater() immediately when the user closed the window. The ExportTask was a child QObject of the dialog, so it got destroyed while its Run() method was still executing in the worker thread, leading to a use-after-free on encoder_->Close(). Defer deletion until the QFutureWatcher reports that the task has actually finished. A new task_finished_ flag tracks this so closeEvent only deletes when it is safe, and TaskFinished() closes the dialog (which now deletes instead of calling close() again while the task is still alive).
This commit is contained in:
@@ -75,6 +75,8 @@ private:
|
||||
|
||||
bool already_shown_;
|
||||
|
||||
bool task_finished_;
|
||||
|
||||
private slots:
|
||||
void TaskFinished();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user