Subtle KAction::setShortcut bug
Hamish Rodda
rodda at kde.org
Mon Oct 22 13:28:15 BST 2007
Hi,
I've just discovered a bug related to the non-virtual overriding of
QAction::setShortcut() by KAction::setShortcut(). In kate, because
KActionCollection returns QAction* rather than KAction*, the code setting up
the actions used a QAction* to configure the actions. Thus, the QAction
version of setShortcut() is called.
The bug is that KAction doesn't have its default shortcut set, and thus it
thinks that the shortcut is a custom shortcut. So, clicking Defaults in the
shortcut configuration default will clear it (bug), and it will get saved to
the config as a custom shortcut (which is also a bug but a less harmful one).
This can of course be fixed in the app with a whole bunch of casts. However,
I'm concerned that it will happen in many applications.
We could listen for ActionChanged events and respond to them, but that would
be quite an ugly hack.
I'd be interested to find out why the return value of
KActionCollection::addAction(KStandardAction::StandardAction, ...) was made a
QAction* rather than a KAction* - is there any reason for this? (I could at
least avoid heaps of casts).
Perhaps an audit of setShortcut calls could be performed... *shudder*
Any other ideas?
Cheers,
Hamish.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071022/f4d6fffa/attachment.sig>
More information about the kde-core-devel
mailing list