Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-08-02 Thread Giuseppe D'Angelo via Interest
Il 31/07/19 23:22, Nikos Chantziaras ha scritto: static void constructor() __attribute__((constructor)); static void constructor(){    qmlRegisterType("ClassName", 1, 0, "ClassName"); } Maybe it helps. Thanks! I didn't know about that one. You can do that in pure C++, by the way; just

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-08-02 Thread Nikos Chantziaras
(CC'ing the list as it might be of interest.) I didn't think volatile would affect the linker. That might indeed work if the llvm people think so. I'll try and run some tests when I get to it. Thanks! On 02/08/2019 09:54, Dmitriy Purgin wrote: Oh, thanks, I didn't get it from the

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-31 Thread Nikos Chantziaras
On 29/07/2019 23:50, Tomas Konir wrote: I'm using C constructor attribute with no problems. Code like below at each class cpp file. static void constructor() __attribute__((constructor)); static void constructor(){    qmlRegisterType("ClassName", 1, 0, "ClassName"); } Maybe it helps.

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Thiago Macieira
On Monday, 29 July 2019 13:28:04 PDT Nikos Chantziaras wrote: > > This is only required when referring to it by name, such as in old-style > > signal-slot connection, QML, D-Bus, etc. > > They're new-style connections, but are sometimes of QueuedConnection > type since some connections are used

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Thiago Macieira
On Monday, 29 July 2019 09:25:04 PDT Tomasz Olszak wrote: > What's is the cons of putting something like that in anonymous namespace > instead of constructor? It's run on program load, before main(), even if the type is never used. -- Thiago Macieira - thiago.macieira (AT) intel.com Software

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Tomas Konir
po 29. 7. 2019 v 21:00 odesílatel Nikos Chantziaras napsal: > The linker might remove it from the executable when linking statically, > because 'registerHelper' is not referenced anywhere. > > > On 29/07/2019 19:25, Tomasz Olszak wrote: > > What's is the cons of putting something like that in

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Nikos Chantziaras
On 28/07/2019 07:15, Thiago Macieira wrote: On Friday, 26 July 2019 17:35:03 PDT Nikos Chantziaras wrote: I didn't (although I use Q_ENUM, but it does the same job.) But there's no constructor to put qRegisterMetaType() in. It's an enum. There's no constructor. Some enums are in a namespace,

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Nikos Chantziaras
The linker might remove it from the executable when linking statically, because 'registerHelper' is not referenced anywhere. On 29/07/2019 19:25, Tomasz Olszak wrote: What's is the cons of putting something like that in anonymous namespace instead of constructor? namespace { struct

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-29 Thread Tomasz Olszak
What's is the cons of putting something like that in anonymous namespace instead of constructor? namespace { struct RegisterHelper { RegisterHelper() { qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaTypeStreamOperators(); } }; static RegisterHelper

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-27 Thread Thiago Macieira
On Friday, 26 July 2019 17:35:03 PDT Nikos Chantziaras wrote: > I didn't (although I use Q_ENUM, but it does the same job.) But there's > no constructor to put qRegisterMetaType() in. It's an enum. There's no > constructor. Some enums are in a namespace, some are in a class, but > even with an

Re: [Interest] Is it safe to call qRegisterMetaType() before main()?

2019-07-26 Thread Nikos Chantziaras
On 25/07/2019 06:20, Thiago Macieira wrote: On Wednesday, 24 July 2019 09:05:02 PDT Nikos Chantziaras wrote: On 24/07/2019 17:23, Thiago Macieira wrote: On Tuesday, 23 July 2019 07:27:27 PDT Nikos Chantziaras wrote: Ugh. Having the call happen on every object creation sounds even uglier. It