Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): non-default filters can erase layer
When filtering, we use a listener to trigger processing the image whenever a filter setting changes. For example, if the user changes from canny to depth, and auto-process is enabled, we re-process the layer with new filter settings. The filterer has a method to reset its ephemeral state. This includes the filter settings, so resetting the ephemeral state is expected to trigger processing of the filter. When we exit filtering, we reset the ephemeral state before resetting everything else, like the listeners. This can cause problem when we exit filtering. The sequence: - Start filtering a layer. - Auto-process the filter in response to starting the filter process. - Change the filter settings. - Auto-process the filter in response to the changed settings. - Apply the filter. - Exit filtering, first by resetting the ephemeral state. - Auto-process the filter in response to the reset settings.* - Finish exiting, including unsubscribing from listeners. *Whoops! That last auto-process has now borked the layer's rendering by processing a filter when we shouldn't be processing a filter. We need to first unsubscribe from listeners, so we don't react to that change to the filter settings and erroneously process the layer. Also, add a check to the `processImmediate` method to prevent processing if that method is accidentally called without first starting the filterer. The same issue could affect the segmenyanything module - same fixes are implemented there.
- Loading branch information