darktable-org / darktable-org/lua-scripts
help wanted: strange / unknown behaviour of gui.create_job
Personne n'a encore pris cette issue.
- Langage dominant
- Lua
- Étoiles
- 219
- Forks
- 142
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I'm currently writing (or, trying to write 🙄) a lua script that will generate the preview cache for selected images (without leaving dt to start the external program...). Basically, it seems to work but I see two strange things that I don't understand right now.
First, the essential parts of my script:
local function stop_job( job )
job.valid = false
end
local function create_previews()
job = dt.gui.create_job( "generating previews", true, stop_job )
local images = dt.gui.action_images
for i,image in pairs(images) do
if job.valid then
image:generate_cache( true, 0, 8 )
job.percent = i / #images
dt.control.sleep( 1 ) -- without this, the job cannot be aborted
else
break
end
end
if job.valid then -- without this, dt crashes with an exception in dt_pthread_mutex_destroy() after aborting the job
job.valid = false
end
end
the create_previews function will be called from a registered action.
My two questions:
-
Without the sleep() I cannot stop the running job. After starting the job, the progress bar is shown and when I hit the 'X' nothing happens until the for loop processed all images. Then the stop_job() is called. With the sleep the stop_job is called after processing the current image and the job terminates as desired.
-
When I set the job.valid to false after the loop it only works as long as the job is not terminated via the stop_job function. As this already sets the job to invalid I guess it is already destroyed and in the second job.valid=false dt crashes with an exception in dt_pthread_mutex_destroy.
Both phenomena are completely understandable, but: I see a lot of scripts that execute job.valid=false twice (when aborted) and seem to rely on stopping without a call to sleep(). Hmmm. What I'm missing here?
I hope you can clarify this,
thanks a lot!
Christian
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’action enregistrée affichée et reproduisez l’annulation de dt.gui.create_job avec et sans dt.control.sleep. Suivez le cycle de vie de job.valid autour de stop_job et de l’affectation finale, en utilisant l’implémentation de la Lua API ou les scripts existants mentionnés par l’issue. La tâche est terminée lorsque le comportement d’annulation et l’utilisation sûre du cycle de vie du job sont clarifiés ou corrigés sans le crash signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- lua
- Domaine
- api
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100