diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2022-06-02 12:20:17 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-06-02 12:20:17 +0300 |
commit | f4456a4d3c9767da76041bfa48e623cf6afa59ce (patch) | |
tree | 6d489e1244cd6024ac3f9e53d850548e73e51824 /source/blender/blenkernel/BKE_callbacks.h | |
parent | 40ecf9d606358d773bfe977e6bc85580e5818cc6 (diff) |
Expose background job info to Python
Add `bpy.app.is_job_running(job_type)` as high-level indicator. Job
types currently exposed are `WM_JOB_TYPE_RENDER`,
`WM_JOB_TYPE_RENDER_PREVIEW`, and `WM_JOB_TYPE_OBJECT_BAKE`, as strings
with the `WM_JOB_TYPE_` prefix removed. The functions can be polled by
Python code to determine whether such background work is still ongoing
or not.
Furthermore, new app handles are added for
`object_bake_{pre,complete,canceled}`, which are called respectively
before an object baking job starts, completes sucessfully, and stops due
to a cancellation.
Motivation: There are various cases where Python can trigger the
execution of a background job, without getting notification that that
background job is done. As a result, it's hard to do things like
cleanups, or auto-quitting Blender after the work is done.
The approach in this commit can easily be extended with other job types,
when the need arises. The rendering of asset previews is one that's
likely to be added sooner than later, as there have already been
requests about this.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D14587
Diffstat (limited to 'source/blender/blenkernel/BKE_callbacks.h')
-rw-r--r-- | source/blender/blenkernel/BKE_callbacks.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_callbacks.h b/source/blender/blenkernel/BKE_callbacks.h index 8b2af96a063..d8c67c52edc 100644 --- a/source/blender/blenkernel/BKE_callbacks.h +++ b/source/blender/blenkernel/BKE_callbacks.h @@ -97,6 +97,9 @@ typedef enum { BKE_CB_EVT_XR_SESSION_START_PRE, BKE_CB_EVT_ANNOTATION_PRE, BKE_CB_EVT_ANNOTATION_POST, + BKE_CB_EVT_OBJECT_BAKE_PRE, + BKE_CB_EVT_OBJECT_BAKE_COMPLETE, + BKE_CB_EVT_OBJECT_BAKE_CANCEL, BKE_CB_EVT_TOT, } eCbEvent; |