[Development] RCC XML and options

John M. Dlugosz r9pbdtabzx at snkmail.com
Thu Sep 4 20:46:04 CEST 2014


On 9/4/2014 1:03 PM, André Pönitz apoenitz-at-t-online.de |Qt Dev mailing list/Qt| wrote:
> [Out of curiosity, what are the "standard platform tools" in this case?] 
MSBuild.  Runs from automated build server, testing server, as well as in the desktop IDE.
>> Let me make sure I understand what that’s used for: The named function
>> needs to be called at some point to make the resources available, but is
>> otherwise not used, right? Different *.qrc files prepared by different
>> developers in different parts of the code base (in the same resulting
>> executable file) are distinguished by the ‘prefix’, right?
>>
>> If that’s right, couldn’t the generated code contain a dummy object using
>> the “static constructor” technique to cause the registration function to
>> be called sometime before main(), and not need an exposed name at all?
> That's already happening. Of course, the "static constructor" must be
> triggered _somehow_, e.g. from the dynamic loader.
>
>> (Update:  it looks like a macro is generating a static object with a
>> ctor, but it is still necessary to explicitly call the init function for
>> it to work.
> Did you try and it didn't work without explicitly calling the setup
> function? How did you build that application?
Yes.  I took out the Q_INIT_RESOURCE line, and the icons were missing in the Qt-drawn window.
With the generated resource cpp file in the main EXE (not in some loaded DLL), the static constructor is called before main(), with no worry about DLL loading.  I'm familiar with such things and DLLs in general, though.

My quick reading of the macros in the generated code is that a static ctor is being set up, calling the same function that Q_INIT_RESOURCE does; so the only reason for the latter is if the resource is needed for other static ctor functions earlier than its automatic time.  It also seemed that the 'name' still needs to be unique since it's exposed even if it is going to be used automatically.

I was surprised when it didn't work automatically.

Thanks for your insight.
—John





More information about the Development mailing list