title: Destructor is called multiple times and out of place
body: <p>The problem in ma Model class is with processing each mesh it's composed of. When it consists of 7 meshes, firstly the destructor is called 21 times. And after exiting the program it's called 14 times. Really don't know what I am doing wrong. I was able to trach the problem to this particular pice of code.</p>
  
  <pre><code>void Model::processNode(aiNode *node, const aiScene *scene) {
      for(unsigned int i = 0; i &lt; node-&gt;mNumMeshes; i++) {
          aiMesh* mesh = scene-&gt;mMeshes[node-&gt;mMeshes[i]];
          mMeshes.push_back(processMesh(mesh, scene));
      }
      for(unsigned int i = 0; i &lt; node-&gt;mNumChildren; i++) {
          processNode(node-&gt;mChildren[i], scene);
      }
  }
  </code></pre>
  
  <p>mMeshes is a private vector of meshes for single Model object.</p>
  
  <p>Edit:</p>
  
  <p>To clarify, the problem is that when the destructor of Mesh class is not commented out, it completely destroys everything in mMeshes vector. This is the destructor of Mesh</p>
  
  <pre><code>Mesh::~Mesh () {
      glDeleteVertexArrays(1, &amp;mVAO);
      glDeleteBuffers(NUM_BUFFERS, mVBOs);
  }
  </code></pre>
  
  <p>this is the vector of Meshes.</p>
  
  <pre><code>std::vector&lt;Vertex&gt; mVertices;
  </code></pre>
  
  <p>and header of processNode, it just creates new mesh and returns it to the vector.</p>
  
  <pre><code>Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene);
  </code></pre>