[patch] klineedit: use isEmpty()

Thiago Macieira thiago at kde.org
Tue Apr 8 12:58:39 BST 2008


On Tuesday 08 April 2008 12:19:41 Jaroslaw Staniek wrote:
> Andreas Hartmetz said the following, On 2008-04-08 10:04:
> > Haha, great. I read some QString code (*) to confirm my suspicion that
> > isNull() is just a deprecated way of saying isEmpty(). The thing is that
> > (shock) they actually differ! isNull() will check if the private class
> > instance is the shared null, isEmpty() will check for string length zero.
> > I conclude that QString::isNull() is Evil because in 99,5% of cases you
> > shouldn't care why and how a string is/has become empty.
> > (This is not news to many, I know)
> >
> > (*) the difference is actually documented, too :)
>
> Yeah, so what now? Time to inspect all the code for isNull() and change?
>
> Sometimes I also think about Krazy check for this...
>
> In fact I do pay attention to isEmpty()/isNull() differences, coming from
> the old Qt era, because I use both methods (on purpose) in database apps
> where we have heavy use of EMPTY and NULL properties, e.g. in Kexi.

Agreed with both here.

In *most* cases, you should use isEmpty().

Only when you have a specific need to check if a certain string is empty but 
not null should you check for isNull(). There are only a few contexts for 
that; SQL is one of them.

In general, we try to avoid that in the API in Qt and KDE should do the same.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- 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/20080408/63e70ba4/attachment.sig>


More information about the kde-core-devel mailing list