CuteMarkEd
CuteMarkEd copied to clipboard
Check if map of custom shortcuts contains empty values before applying them
Default shortcut did not always work because map with custom shortcuts might contain entries with empty values. Not sure why there are entries without value at all. But this fixes the problem for me.
Hi @MPohlVIC,
Thank you for your contribution! I will take a look at it as fast as possible. My time is a little limited right now.
Bye, Christian
The reason for empty entries is fairly easy. In OptionsDialog::saveState()
, we go through the list of all rows in the shortcut table and add a custom shortcut regardless of the row content:
// shortcut settings
for (int i = 0; i < ui->shortcutsTable->rowCount(); ++i) {
QKeySequence customKeySeq(ui->shortcutsTable->item(i, 1)->text());
options->addCustomShortcut(actions[i]->objectName(), customKeySeq);
}
Normally this should not be a problem, since initially all custom shortcuts are equal to the default shortcut of an action. So the custom shortcut can, AFAICS, only be empty if the default shortcut was empty.
Only exception I can think of is an later added default shortcut for an already existing action.
I would really like to understand the root cause of the problem.
I tried to reproduce the error but I did not succeed. Maybe some issue with QSettings? I cleared them manually and it never re-surfaced again. I'll keep watching for it but in the meanwhile this pull request could be closed.