[Kde-pim] KDE/kdepim/libkdepim

Aaron J. Seigo aseigo at kde.org
Wed Feb 7 23:24:32 GMT 2007


On February 7, 2007, David Faure wrote:
> On Wednesday 07 February 2007, Aaron J. Seigo wrote:
> > SVN commit 631408 by aseigo:
> >
> > the const cast is ugly as heck, but QMap::operator[]const returns a
> > -copy- of the object, so returning the address of it means returning the
> > address of a temporary. so we need to use the non-const version of the
> > QMap (which returns a reference on operator[]) to avoid that.
> >
> > compiler warnings are neat. how else can you make sure your code is safe
> > -and- ugly? =)
> >
> >
> >  M  +1 -1      pluginloaderbase.cpp
> >
> >
> > --- trunk/KDE/kdepim/libkdepim/pluginloaderbase.cpp #631407:631408
> > @@ -58,7 +58,7 @@
> >    }
> >
> >    const PluginMetaData * PluginLoaderBase::infoForName( const QString &
> > type ) const { -    return mPluginMap.contains( type ) ?
> > &(mPluginMap[type]) : 0 ; +    return mPluginMap.contains( type ) ?
> > &(const_cast<PluginLoaderBase*>(this)->mPluginMap[type]) : 0 ; }
>
> Ugly indeed. Especially the double lookup (which was already there).
> This should use a simple mPluginMap.value(type, 0) and store pointers into
> the map, or return by value instead of by pointer (assuming that class has
> support for "invalid")...

both sensible solutions, but really up to the kdepim people (who likely know 
the implications of either change better than i do without a bunch of reading 
the codebase). i just wanted something that wasn't broken in the meantime.

bon appetite. =)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

Full time KDE developer sponsored by Trolltech (http://www.trolltech.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070207/eb2454cb/attachment.sig>
-------------- next part --------------
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/


More information about the kde-pim mailing list