What is the bug or the crash?
When using the newish QgsTaskWithSerialSubTasks to run a sequence of subtasks, the finished() method is never called on the subtasks.
For other tasks, finished() is called by QgsTaskManager when the task's status changes to either Completed or Terminated, but subtasks of a QgsTaskWithSerialSubTasks are not controlled by QgsTaskManager, and so finished() is never called.
Steps to reproduce the issue
- Create a
QgsTask subclass that defines both a run() and a finished() method. Both can be no-ops.
- Create an instance of
QgsTaskWithSerialSubTasks, and use its addSubTask method to add an instance of the task class defined in step 1
- Run the
QgsTaskWithSerialSubTasks instance by adding it to QgsApplication.instance().taskManager()
The sub-task instance's finished() method is never called.
Versions
3.36 and newer
Supported QGIS version
New profile
Additional context
For my purposes, I'd like finished() to be called on each subtask before the next subtask is started. However, because finished runs in the main thread, that would require forced synchronization with the main thread after each sub-task completes, which may not fit the use case QgsTaskWithSerialSubTasks is designed for. But either way, finished() should be called at some point on each subtask.
What is the bug or the crash?
When using the newish
QgsTaskWithSerialSubTasksto run a sequence of subtasks, thefinished()method is never called on the subtasks.For other tasks,
finished()is called byQgsTaskManagerwhen the task's status changes to eitherCompletedorTerminated, but subtasks of aQgsTaskWithSerialSubTasksare not controlled byQgsTaskManager, and sofinished()is never called.Steps to reproduce the issue
QgsTasksubclass that defines both arun()and afinished()method. Both can be no-ops.QgsTaskWithSerialSubTasks, and use itsaddSubTaskmethod to add an instance of the task class defined in step 1QgsTaskWithSerialSubTasksinstance by adding it toQgsApplication.instance().taskManager()The sub-task instance's
finished()method is never called.Versions
3.36 and newer
Supported QGIS version
New profile
Additional context
For my purposes, I'd like
finished()to be called on each subtask before the next subtask is started. However, becausefinishedruns in the main thread, that would require forced synchronization with the main thread after each sub-task completes, which may not fit the use case QgsTaskWithSerialSubTasks is designed for. But either way,finished()should be called at some point on each subtask.