What to do about KShortcutsEditor and undo

Michael Jansen kde at michael-jansen.biz
Tue May 20 23:44:34 BST 2008

> > What is the correct behaviour for the dialog upon destruction when there
> > are unsaved changes? /me thinks undoing the changes. That's what i
> > implemented.
> Due to parents deleting childs, and in principle as well, it's a bad
> idea in library code to do anything nontrivial involving objects you
> don't own in the destructor.

Perhaps. But what is beeing done is the right thing. So the point to work on 
is "objects you don't own" if you ask me.

> See above, the code of the KWin effects module will crash if written
> the obvious way. This is really the killer argument, the others don't
> matter nearly as much. You would have to take special measures to
> avoid the crash and I really really don't want to force that upon API
> users. A forgotten undo() would have less dramatic consequences and
> its purpose would be very obvious, leading to code that is easier to
> understand. Understand as in "know what every single line is good for,
> without comments".

Yes. But with your change you would have to take extra steps to ensure correct 
behavior. I mean that calling undo before destruction.

> Caring about destruction order is not a productive way to spend time.

OK. My Solutions

1. Reparent the action collections to the kshortcutseditor in qt tradition. 
Change the doc to reflect that.
2. Use the QPointer class

I would go for 1.


Michael Jansen
Available for contract work ( Development / Configuration Management )

More information about the kde-core-devel mailing list