module main;
import dsfml.graphics.all;
import dsfml.window.all;
import std.stdio;
class ImageWrapper
{
private Image image;
this()
{
image = new Image(200, 200, Color.WHITE);
}
~this()
{
image.dispose();
}
}
void main()
{
try
{
try
auto img = new ImageWrapper;
catch(Exception e)
writeln(e.msg);
}
catch(Error e)
writeln(e.msg);
}
I'm guessing this throws an exception because the libraries are unloaded at the end of main(), and destruction occurs by the garbage collector after. If that's the case, then does that mean any wrappers I create need to be structs? Or am I misdiagnosing?