Skip to content

Draft: add a lock to prevent files being open while the processing thread is running with the intent to update gfit

Adrian Knagg-Baugh requested to merge stopcrashonopen into master

This adds a new element in the com global data structure: gboolean thread_will_clobber_gfit. It is initialised to FALSE on startup.

open_single_image() now checks that this is FALSE before opening a file and throws an error if not.

Each threaded function that intends to update gfit on completion has to set com.thread_will_clobber_gfit to TRUE when it starts, and its corresponding idle must set it FALSE again to remove the lock. end_generic() now includes the instruction to set it FALSE again which may catch several functions as it is the default idle.

I've implemented this for denoising, which was where I found the original crash, plus initially a few other functions (starnet, FFT, RTdeconvolution). Starnet didn't actually cause a crash but the behaviour was still bad - if you opened a file while starnet++ was running, it would open fine and then the starnet thread would open its result back over the top of the newly opened file.

If this seems like the right approach and doesn't cause unexpected consequences, I'll draw up a list of the other threaded functions that should have this behaviour added.

Closes #953 (closed)

Edited by Adrian Knagg-Baugh

Merge request reports