From: Mikko Rasa Date: Wed, 18 Nov 2015 19:04:02 +0000 (+0200) Subject: Clear manager in destructors of individual resource classes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8e51e1e7089d79359ec584bb4292b6cb2ecfd495;p=libs%2Fgl.git Clear manager in destructors of individual resource classes If the resource is destroyed while being loaded asynchronously, loading has to be stopped before the derived class is destroyed. The Resource destructor is too late for that. --- diff --git a/source/mesh.cpp b/source/mesh.cpp index 8f7c517b..d0e71489 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -40,6 +40,7 @@ void Mesh::init(ResourceManager *rm) Mesh::~Mesh() { + set_manager(0); delete vbuf; delete ibuf; if(vao_id) diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 41763586..de754209 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -40,6 +40,11 @@ Texture2D::Texture2D(ResourceManager *m): allocated(0) { } +Texture2D::~Texture2D() +{ + set_manager(0); +} + void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) { if(width>0) diff --git a/source/texture2d.h b/source/texture2d.h index 7504f321..71e04b57 100644 --- a/source/texture2d.h +++ b/source/texture2d.h @@ -43,6 +43,7 @@ private: public: Texture2D(ResourceManager * = 0); + virtual ~Texture2D(); /** Defines storage structure for the texture. Must be called before an image can be uploaded. Once storage is defined, it can't be changed. */