From 5a4011c3092df928fc0f1ed80b71f7f1ef4e371a Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Thu, 23 Nov 2023 16:07:46 +0100 Subject: [PATCH] scheduler: Set reasons in cupsdSetJobState only if we call finalize_job later --- scheduler/job.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scheduler/job.c b/scheduler/job.c index 36474ea74a..6efbaf85e5 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -2593,8 +2593,16 @@ cupsdSetJobState( case IPP_JSTATE_CANCELED : case IPP_JSTATE_COMPLETED : set_time(job, "time-at-completed"); - ippSetString(job->attrs, &job->reasons, 0, "processing-to-stop-point"); - break; + + /* + * Set the reasons here only if we call finalize_job() + * at the end of this function, so finished jobs can get proper + * reasons message there... + */ + + if (action > CUPSD_JOB_DEFAULT || !job || !job->printer) + ippSetString(job->attrs, &job->reasons, 0, "processing-to-stop-point"); + break; } /* -- 2.47.2