Delphi - How to correctly register a graphic class since XE8? : <p>I'm writing a Delphi package, which provides a new custom TGraphic object, allowing to read a new image format in VCL components like TImage.</p>

<p>I originally developed this package with RAD Studio XE7, and it worked well. However I migrated recently to a newer RAD Studio compiler version, and although my package continues to work properly on that new version, I noticed a strange bug that never appeared before. </p>

<p>I have a form with several components, some of them are TImage components. Immediately after opening the IDE, the first time I open my project in design time, all the TImage components containing my custom TGraphic component loose their content. If I close then reopen the project, the images reappear, and the bug no longer happen until I close and reopen my IDE.</p>

<p>I dug in my code to understand what may cause the issue. To register my custom TGraphic component, I use the class initialization section, in which I wrote the following code:</p>

<pre class="lang-pascal prettyprint-override"><code>initialization
begin
    Vcl.Graphics.TPicture.RegisterFileFormat('svg', 'Scalable Vector Graphics', TWSVGGraphic);
end;
</code></pre>

<p>However I found that, since the XE8 compiler version, the TImage constructor is called before my initialization section, causing thus apparently the above mentioned issue. All the compiler versions since XE8 are affected, but this bug never happened on XE7 or earlier. So something changed since XE8.</p>

<p>Here are my questions:</p>

<ul>
<li>Is the way I use for register my custom graphic class correct?</li>
<li>If not, what is the correct way to do that?</li>
<li>As something seems different since XE8, what it the new correct manner to register my graphic component?</li>
<li>Did anyone else faced the same issue? How he resolved it?</li>
<li>Is this may be a new RAD Studio bug, or the issue is rather on my side?</li>
</ul>
