Jump to content
Mike Scott

Datamodule with ImageCollection of PNGs loading with packages

Recommended Posts

I have a datamodule with imagecollections holding .PNG files. If I compile a Debug build (no packages) all is well. However, a Release build with various packages including vcl;vclx;rtl;vclimg;vclSmp;vclwinX;bindengine; reliably gives trouble. I CoInitialize before and CoUninitialize after the load. The loading mechanism which gives an AV in vcl280.bpl.

 

Image 1 shows what Eurekalog diagnoses.

The images are all PNG files.

Image 2 shows the source. I get an AV when creating the DatamoduleAlImages or when I get to Application.Run.

imagelist load.png

imagelist source dpr.png

Share this post


Link to post

That's not how you use coInitialize/coUninitialize.

First of all check the return value of coInitialize and don't call coUnititialize unless the return status indicated that it succeeded. Read the documentation.

And don't call coUninitialize until you are sure that everything using the thread apartment is done with it. Since you're doing this in the main thread and you don't know what else is using it you are best of doing it just before the final end. Normally this is something that would be done in the initialization and finalization sections of a unit.

Finally, use coInitializeEx instead.

  • Like 1

Share this post


Link to post

Problem solved, thanks.

 

I hope this might help someone else with problems loading images for a datamodule!

 

Cheers -- MIke

coInitialize.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×