[Patch] Fix undeleted "static QFont *_font" in kglobalsettings.cpp

Friedrich W. H. Kossebau kossebau at kde.org
Thu Dec 4 16:03:43 GMT 2008


Hi Louai,

Am Donnerstag, 4. Dezember 2008, um 15:03 Uhr, schrieb Louai Al-Khanji:
> On Thu, Dec 4, 2008 at 3:16 PM, Friedrich W. H. Kossebau
>
> <kossebau at kde.org> wrote:
> > Two best practice questions, for handling the "QFont* mFonts[FontCount]"
> > : 1. How to set an array of pointers all to 0 most efficiently (mFonts)?
>
> Either memset or just loop through it.

So no built-in mechanism? Alright.

> > 2. How to mark the number of entries in an enum, so adding one more
> > increases that number (FontCount) automatically?
>
> I don't know if there is a clean way to do it. If it is part of a
> QObject you can use the meta object system to get the count. Otherwise
> I tend to do something like this:
>
> enum Foo {
>     Bar,
>     Baz,
>     FooSentinel /*  Keep as last entry, gives number of enum elements */
> }

So is Bar always assigned to 0 by definition of C++?
And is there a nice KDE/Qt-pattern for naming the sentinel element? :)

Thanks
Friedrich
-- 
Okteta - KDE 4 Hex Editor - http://utils.kde.org/projects/okteta




More information about the kde-core-devel mailing list