darktable-org / darktable-org/lua-scripts
help wanted: strange / unknown behaviour of gui.create_job
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Lua
- Estrellas
- 219
- Forks
- 142
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la acción registrada mostrada y reproduce la cancelación de dt.gui.create_job tanto con dt.control.sleep como sin él. Rastrea el ciclo de vida de job.valid en torno a stop_job y a la asignación final, utilizando la implementación de la Lua API o los scripts existentes mencionados por el issue. La tarea estará terminada cuando el comportamiento de cancelación y el uso seguro del ciclo de vida del job estén aclarados o corregidos sin que se produzca el crash informado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- lua
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100