Cleanup: simplify wm_jobs_timer_end, wm_jobs_timer

The logic in wm_jobs_timer made it seem as if timers might be shared
between wmJob's however this is never the case.

Replace a loop on wmJob's with a lookup & NULL check.
This commit is contained in:
Campbell Barton
2023-08-30 12:17:29 +10:00
parent 09471c8636
commit d7b9467f19

View File

@@ -613,21 +613,17 @@ void WM_jobs_kill(wmWindowManager *wm,
void wm_jobs_timer_end(wmWindowManager *wm, wmTimer *wt)
{
LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->wt == wt) {
wm_jobs_kill_job(wm, wm_job);
return;
}
wmJob *wm_job = static_cast<wmJob *>(BLI_findptr(&wm->jobs, wt, offsetof(wmJob, wt)));
if (wm_job) {
wm_jobs_kill_job(wm, wm_job);
}
}
void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
{
LISTBASE_FOREACH_MUTABLE (wmJob *, wm_job, &wm->jobs) {
if (wm_job->wt != wt) {
continue;
}
wmJob *wm_job = static_cast<wmJob *>(BLI_findptr(&wm->jobs, wt, offsetof(wmJob, wt)));
if (wm_job) {
/* running threads */
if (wm_job->threads.first) {
/* let threads get temporary lock over main thread if needed */