I’m not sure I identified correctly the problem but here is what is happening :
1- A window in opened and it loads data from the database that is used to populate container controls created on the fly.
2- Each of the created Container Controls contain various controls among wihich a Canvas Class (to show pictures) with a Webpictures array property that stores the pictures. The pictures used to populate the canvas are downsized versions of the original picture. Their weight is around 100 ko each.
3- The way code is built, each container control should be created one after the other. Data and pictures are added at creation.
4- In reality, container controls will show with data but pictures are loaded progressively after all controls have already shown. It is, of course, especially obvious when many containers are created. It may take over 1 minute to load all pictures ( test scenario of 30 containers with 2 pictures each )
5- I can live with the delay but the problem occurs when the main window is closed before all canvas paint event has executed successfully. I get nil exception errors for the canvasses that are still loading pictures.
I’ve tried closing each container object, setting classes or the whole window to Nil but that did not work. I’ve also created the containers as WeakRefs but I’m not sure I used them properly.
How can I handle such situations?