title: std::shared_ptr _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) when changing pointer
body: <p>When this function runs, I get the debug assertion error as described in the title on the line <code>sprite = spr;</code>. If I add <code>sprite.reset();</code> before that, it crashes on the line with <code>sprite.reset();</code>. The pointer is being stored elsewhere, in <code>static std::map&lt;std::string,sf::Sprite&gt; ResourceManager::sprites;</code>, so I would not expect the destructor to be called for the sf::Sprite either (although I have a suspicion it may be because they are being stored in a static object...?)</p>
  
  <p>VisibleGameObject.h</p>
  
  <pre><code>#ifndef VISIBLEGAMEOBJECT_H
  #define VISIBLEGAMEOBJECT_H
  
  #include "Game.h"
  
  //just for keeping track of the sprite and drawing
  
  class VisibleGameObject{
  public:
      VisibleGameObject(){}
      VisibleGameObject(const std::string&amp; name);
      ~VisibleGameObject();
  
      std::string getTextureName();
      void setSprite(const std::string&amp; textureName);
      void setSprite(const sf::Texture&amp; texture);
      void setSprite(std::shared_ptr&lt;sf::Sprite&gt; sprite);
  
      void setPosition(float x,float y);
      void setPosition(const sf::Vector2f&amp; position);
  
      void setRotationDegrees(float degrees);
      void setRotationRadians(float radians);
      float getRotationDegrees();
      float getRotationRadians();
  
      void setOrigin(float x,float y);
      void setOrigin(const sf::Vector2f&amp; origin);
  
      sf::Vector2f getSize();
      sf::Vector2f getOrigin();
      sf::Vector2f getPosition();
      std::shared_ptr&lt;sf::Sprite&gt; getSprite();
  
      void draw(tgui::Window* wnd);
  private:
      std::string name;
      std::shared_ptr&lt;sf::Sprite&gt; sprite;
      std::string texture_name;
      bool _loaded;
  };
  
  #endif
  </code></pre>
  
  <p>Extract from VisibleGameObject.cpp</p>
  
  <pre><code>//'sprite' is initialised here
      void VisibleGameObject::setSprite(const std::string&amp; textureName){  
          sprite = std::shared_ptr&lt;sf::Sprite&gt;(ResourceManager::createSpriteFromStoredTexture(textureName,name));
          texture_name = textureName;
          _loaded = true;
      }
  
  
  //error function!
  void VisibleGameObject::setSprite(std::shared_ptr&lt;sf::Sprite&gt; spr){
      sf::Vector2f p(0,0);
      float d = 0;
      if(_loaded){
          p = spr-&gt;getPosition();
          d = spr-&gt;getRotation();
      }
      sprite = spr;
      sprite-&gt;setPosition(p);
      sprite-&gt;setRotation(d);
      _loaded = true;
  }
  </code></pre>
  
  <p>Extract from ResourceManager.cpp</p>
  
  <pre><code>sf::Sprite* ResourceManager::createSpriteFromStoredTexture(const std::string&amp; texturename,const std::string&amp; spritename){
      sf::Sprite spt;
      spt.setTexture(*getTextureByName(texturename));
      std::string name = spritename;
      if(spritename == standard_spt_name){
          name = spritename+std::to_string((long long)spritecount);
          spritecount++;
      }
  
      sprites[name] = spt;
      return &amp;sprites[name];
  }
  </code></pre>
  
  <p>The VisibleGameObject appears to function correctly when being used without changing the sprite with the setSprite function originally described as the problem.</p>