Skip to content
Commit aedb2529 authored by Jakob Petsovits's avatar Jakob Petsovits
Browse files

kcmodule: Don't crash when a configured button action is unsupported

The bounds check in the data() method of PowerButtonActionModel
and SleepModeModel was incomplete, so passing an invalid index
such as -1 (standard value for "not found") could cause a crash.

For power management settings, a user would run into this crash if
their configuration from powerdevilrc listed a power button action
that's not supported on the current system. For example, a user
may have selected "Sleep" as lid action, but subsequently changed
their systemd configuration to disable suspend-to-RAM because it
caused problems. Or they could have migrated their OS to a new
computer which does not support Sleep.

Fixing this allows us to assign currentIndex declaratively
instead of waiting until Component.onCompleted to (hopefully) find
a valid item in the model.

BUG: 482668


(cherry picked from commit 8ecf6430)
parent 38772c27
Pipeline #630360 passed with stage
in 1 minute and 17 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment