The bounds check in the data() method of PowerButtonActionModeland SleepModeModel was incomplete, so passing an invalid indexsuch as -1 (standard value for "not found") could cause a crash.
For power management settings, a user would run into this crash iftheir configuration from powerdevilrc listed a power button actionthat's not supported on the current system. For example, a usermay have selected "Sleep" as lid action, but subsequently changedtheir systemd configuration to disable suspend-to-RAM because itcaused problems. Or they could have migrated their OS to a newcomputer which does not support Sleep.
Fixing this allows us to assign currentIndex declarativelyinstead of waiting until Component.onCompleted to (hopefully) finda valid item in the model.
I split this patch into two parts:
- The first one with the above commit message, which fixes the crash and can be cherry-picked to
Plasma/6.0
. - The second one with just a commit title, which adds
InlineMessage
warnings to tell the user what's actually going on. Due to new strings, this should not go intoPlasma/6.0
.