Cleanup: Simplify job custom data query API

There were two calls to access job's custom data. One of them
ignored job type, the other one ignored job owner.

Now there is a single function to access job's custom data.
If the job type or owner is not relevant NULL or WM_JOB_TYPE_ANY
can be passes explicitly.

Differential Revision: https://developer.blender.org/D14803
This commit is contained in:
Sergey Sharybin 2022-04-29 16:41:02 +02:00
parent 2f49908a5e
commit 5d84d9b0d6
4 changed files with 9 additions and 18 deletions

View File

@ -1146,7 +1146,8 @@ void RENDER_OT_render(wmOperatorType *ot)
Scene *ED_render_job_get_scene(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(
wm, CTX_data_scene(C), WM_JOB_TYPE_RENDER);
if (rj) {
return rj->scene;
@ -1158,7 +1159,8 @@ Scene *ED_render_job_get_scene(const bContext *C)
Scene *ED_render_job_get_current_scene(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(
wm, CTX_data_scene(C), WM_JOB_TYPE_RENDER);
if (rj) {
return rj->current_scene;
}

View File

@ -713,7 +713,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
ID *parent = (ID *)parentp;
MTex *slot = (MTex *)slotp;
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ShaderPreview *sp = static_cast<ShaderPreview *>(WM_jobs_customdata(wm, area));
ShaderPreview *sp = static_cast<ShaderPreview *>(
WM_jobs_customdata_from_type(wm, area, WM_JOB_TYPE_LOAD_PREVIEW));
rcti newrect;
bool ok;
int newx = BLI_rcti_size_x(rect);

View File

@ -1322,8 +1322,7 @@ const char *WM_jobs_name(const struct wmWindowManager *wm, const void *owner);
* Time that job started.
*/
double WM_jobs_starttime(const struct wmWindowManager *wm, const void *owner);
void *WM_jobs_customdata(struct wmWindowManager *wm, const void *owner);
void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, const void *owner, int job_type);
bool WM_jobs_is_running(const struct wmJob *wm_job);
bool WM_jobs_is_stopped(const wmWindowManager *wm, const void *owner);

View File

@ -280,20 +280,9 @@ const char *WM_jobs_name(const wmWindowManager *wm, const void *owner)
return NULL;
}
void *WM_jobs_customdata(wmWindowManager *wm, const void *owner)
void *WM_jobs_customdata_from_type(wmWindowManager *wm, const void *owner, int job_type)
{
wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
if (wm_job) {
return WM_jobs_customdata_get(wm_job);
}
return NULL;
}
void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
{
wmJob *wm_job = wm_job_find(wm, NULL, job_type);
wmJob *wm_job = wm_job_find(wm, owner, job_type);
if (wm_job) {
return WM_jobs_customdata_get(wm_job);