KColorScheme - additional (convenience) ctors

Simon Hausmann hausmann at kde.org
Tue Sep 4 11:36:09 BST 2007


On Sunday 02 September 2007 20:06:12 Matthew Woehlke wrote:
> Simon Hausmann wrote:
> > I suggest to change the signature of the constructor that takes a const
> > QWidget & to take a const QWidget *. Nobody passes around QWidget
> > references, so everyone using this constructor has to dereference the
> > widget to pass for no good reason IMHO.
>
> Thanks for the feedback. I thought about that also, the problem is that
> passing a NULL reference is not valid. By requiring a reference rather
> than a pointer, this makes it explicitly clear that you must pass in a
> real object. Otherwise, the ctor has to either throw an exception or
> abort(), neither of which it currently does.
>
> So I guess my preference is to make people type an extra '*' (and to
> force them to stop and think about what they're doing, which they need
> to be doing either way). But I'm willing to reconsider. Which evil is
> lesser?

I don't think you gain any readability from requiring people to write the *. 
It just seems inconsistent to me. QLayout::addWidget takes a QWidget pointer, 
too, even though it doesn't make sense to pass a null pointer to it.

Simon
-------------- 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/20070904/4f11d818/attachment.sig>


More information about the kde-core-devel mailing list