]> git.tdb.fi Git - libs/gl.git/commitdiff
Clear manager in destructors of individual resource classes
authorMikko Rasa <tdb@tdb.fi>
Wed, 18 Nov 2015 19:04:02 +0000 (21:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 18 Nov 2015 19:04:02 +0000 (21:04 +0200)
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.

source/mesh.cpp
source/texture2d.cpp
source/texture2d.h

index 8f7c517b2b5360a57d69bded3aed38d32b9ab58c..d0e71489f1f48a22c6de0d1b686648c452024d98 100644 (file)
@@ -40,6 +40,7 @@ void Mesh::init(ResourceManager *rm)
 
 Mesh::~Mesh()
 {
+       set_manager(0);
        delete vbuf;
        delete ibuf;
        if(vao_id)
index 41763586c7dcfc9e81572907b44d00069e5dbf70..de75420973134b3d0aa1d2e2275365778b407915 100644 (file)
@@ -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)
index 7504f321d218543ea151700ed819cdd0eb9cb96d..71e04b576f2b62aa8a93d4c154a3258a596f2bc1 100644 (file)
@@ -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. */