Skip to content

QgsTaskWithSerialSubTasks doesn't call finished() on subtasks #61646

@couteau

Description

@couteau

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

  1. Create a QgsTask subclass that defines both a run() and a finished() method. Both can be no-ops.
  2. Create an instance of QgsTaskWithSerialSubTasks, and use its addSubTask method to add an instance of the task class defined in step 1
  3. 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

  • I'm running a supported QGIS version according to the roadmap.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIAPI improvement only, no visible user interface changesBugEither a bug report, or a bug fix. Let's hope for the latter!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions