Delay deleting replaced textures

This fixes a crash that occurs when connecting to (for example) kaeza's server with a sufficiently empty cache. The crash is caused by an ITexture* that is deleted but still in use, the solution in this patch is to wait until the destruction of the TextureSource (i.e. wait until disconnect) to delete the textures in question.