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

Louai Al-Khanji louai.khanji at gmail.com
Thu Dec 4 16:17:52 GMT 2008


On Thu, Dec 4, 2008 at 6:03 PM, Friedrich W. H. Kossebau
<kossebau at kde.org> wrote:
> 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++?

I believe so, although I do usually set it explicitly.

> And is there a nice KDE/Qt-pattern for naming the sentinel element? :)

No idea :)

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

- Louai




More information about the kde-core-devel mailing list