Particularly since integration of the toolkit-abstraction code, cleanup on failure is really clouding the setup code. Before it was just removeOpenGLContexts(); that had to be remembered, lest we leak, now there is
if (m_toolkit.removeOpenGLContexts) {
m_toolkit.removeOpenGLContexts(m_toolkit.data);
}
(which could have easily been placed in a function called removeOpenGLContexts()).
What should probably be in there instead is a finally cleanup object that just gets cancelled in case the function runs all the way to the end successfully: that way it is impossible to leak resources. (I've already found at least one return where we don't release those resources and thus we're leaking...)
Particularly since integration of the toolkit-abstraction code, cleanup on failure is really clouding the setup code. Before it was just
removeOpenGLContexts();
that had to be remembered, lest we leak, now there is(which could have easily been placed in a function called
removeOpenGLContexts()
).What should probably be in there instead is a
finally
cleanup object that just gets cancelled in case the function runs all the way to the end successfully: that way it is impossible to leak resources. (I've already found at least onereturn
where we don't release those resources and thus we're leaking...)