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

Nikos Chantziaras realnc at gmail.com
Tue Jul 23 16:27:27 CEST 2019


On 23/07/2019 04:53, Thiago Macieira wrote:
> On Monday, 22 July 2019 16:15:05 PDT Hamish Moffatt wrote:
>> On 22/7/19 10:56 pm, Nikos Chantziaras wrote:
>>> In order to avoid calling qRegisterMetaType() in main() (with the
>>> possibility of forgetting to do so,) I instead call it before the
>>> program enters main(), in the implementation file of whoever is the
>>> owner of the type. [...]
>>> [...]
>>>
>>> It "seems to work fine," but is this safe though?
> 
> Actually, yes, so long as you're not using static builds. The metatype system
> depends on only the base containers (QVector, QByteArray), so this should
> work.
> 
> Still, it's ugly. For classes, I recommend putting the registration in the
> constructor. An enum is a different story.

Ugh. Having the call happen on every object creation sounds even uglier. 
It seems it's best to roll our own. Probably a lazily initialized global 
static object that you can add functors to before main() and then run 
all functors of that object in main().

(Off-topic)
It seems the mailing list marks my posts as spam now. Probably because 
I'm using gmane? I'm sending this one without gmane, let's see if it 
makes it through unscathed.


More information about the Interest mailing list