On Tuesday, 3 July 2018 at 07:29:12 UTC, Flaze07 wrote:
class RenderWindow {
private sfRenderWindow* _window;
public {
this() {
_window = sfRenderWindow_create(/*parameters*/);
}
//couple of other functions
~this() {
sfRenderWindow_destroy( window );
}
}
}
//not a very accurate representation, but should get the
message pretty clear
which I am very concerned about leaking resources, the tutorial
did just not use scoped!, instead it directly use new, but what
about leaking resources ?
The only way you're going to be leaking resources is if the app
is long running and the resource objects are never collected. I'd
be more concerned about the nondeterministic nature of the
destructor calls, particularly what happens at app shut down if
the render window destructor is called before any thing that
depends on the graphics context. If the library doesn't account
for that, you'll get random crashes when the app exits.
If you need to release resources while the app is running, just
use resource.destroy(). This will make sure the destructor is
called and the object is reset to its init state, and you can
maintain determinism.