Derelict SFML destructor crashes
Nekroze
nekroze at eturnilnetwork.com
Mon Dec 17 04:08:27 PST 2012
On Monday, 17 December 2012 at 10:56:23 UTC, Jeremy DeHaan wrote:
> Does that mean that putting some form of delete in a struct
> destructor will be called to delete contents or is that still
> considered unsafe?
>
>
> And why don't classes have the same guarantee? Is it because
> they are a reference type and thus handled by the GC rather
> than being a value type?
Structs have their destructors called, as far as i understand, as
soon as you go out of the scope they are defined in. Not sure how
that works with structs that are members of a class but i assume
that has the same problems as a class's destructor.
Classes don't have this guarantee because when they go out of
scope, again as far as i understand, they are just added to the
gc list of things that may need to be cleared (presuming they are
not stored elsewhere still?) and are cleaned whenever the GC
feels like it.
Now what i was thinking as a solution, would it be possible to
manually run the GC cleanup pass at the end of main this way we
know that the GC cleanup would run before main exits and thus
sfml gets unloaded. Although i believe this still doesn't
guarantee that it will think the class is fit for deconstruction
at that point so it may still no work but just a thought.
More information about the Digitalmars-d-learn
mailing list