[Development] Don't use Private *d when your class is immutable

Lars Knoll lars.knoll at qt.io
Fri Mar 3 20:02:18 CET 2017


> On 3 Mar 2017, at 16:54, Marc Mutz <marc.mutz at kdab.com> wrote:
> 
> On Friday 03 March 2017 16:11:54 Thiago Macieira wrote:
>> But we should not add more global tables.
> 
> Apart from "Thiago says so", are there any reasons for this?

How about: "Lars agrees with Thiago"? ;-)

More seriously: constant global tables are perfectly fine. 

But I fully agree with Thiago that I want to avoid adding more global static data (using Q_GLOBAL_STATIC). Reasons are that those are initialised at startup with an undefined initialisation order (and usually worse: destruction on application shutdown). They thus add overhead for each application (in terms of memory usage and startup time), and can cause headaches on shutdown if there are cross dependencies between global statics (we've had those in the past).

Cheers,
Lars




More information about the Development mailing list