Skip to content

applets/brightness: Avoid producing duplicate display sliders

Sometimes a display configuration change results in more than one change signal. These can happen in quick succession of each other.

The async code in ScreenBrightnessControl had a problem with this, because it would sometimes interleave parts of its model update function with another call of the same function. This would cause duplicate brightness sliders to appear for the same display.

The solution is to make sure we don't try to update the model while another update is already running.

One approach would be to simply take QCoro and async calls out in favor of synchronous calls which are easier to reason about. However, this would mean we block plasmashell for a longer time.

Instead, this commit introduces a call guard to the update function which prevents another asynchronous call from entering its main body of code while an existing update is already in the works. After the update has finished, we will repeat the update process in case another update request had been issued in the meantime.

BUG: 493844

Merge request reports