[Aptitude-devel] aptitude-qt VCS usage and code review
Sune Vuorela
nospam at vuorela.dk
Thu Jul 8 08:14:58 UTC 2010
On 2010-07-08, Daniel Burrows <dburrows at algebraicthunk.net> wrote:
> - aptitude generally uses get_foo or getFoo() for accessors, not
> foo().
Most Qt coding docs recommends real hard to use foo(), and that's also
how Qt is done. At least according to the Qt api designers, it gives a
more readable api. It can of course be ignored, but every time a
existing qt developer would like to fix bits and pieces of the frontend
only stuff, it would be a extra barrier of entry.
http://doc.trolltech.com/qq/qq13-apis.html
> * Parameters:
>
> - aptitude always passes non-basic types by const reference unless
> there's a really good reason not to. see, e.g., Package::Package
> and
Yeah. when ever possible, prefer const references over copying the
non basic types.
>
> * Pointers/memory management:
>
> - I see lots of bare pointers here. Could you give me a quick
> summary of how memory management works in the Qt frontend?
> aptitude strongly prefers smart pointers wherever it's feasible
> to use them -- I guess widgets are probably managed by Qt itself,
> but the Package object looks to me like a candidate for some
> sort of smart pointer wrapper.
For making sure to free stuff when done, QObject has a 'All good parents
kill their children'-approach., so as long as the object hierachy is in
place (usually by passing parent in as part of ctor), things will be
cascadedly freed.
Qt has a number of smartpointer classes, QWeakPointer and QSharedPointer
for most usages of raw pointers, and a QScopedPointer, that basically
deletes it contents when it gets out of scope.
Thiago Maciera of Nokia, Qt development Frameworkss has written a long
blog post about the various smartpointers in Qt.
http://labs.trolltech.com/blogs/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/
Thanks for the review
/Sune
More information about the Aptitude-devel
mailing list