Note that there are some explanatory texts on larger screens.

plurals
  1. PODebug assertion failed - Vector iterator not dereferencable
    primarykey
    data
    text
    <p>I have got this Runtime Error when running this code:</p> <pre><code>void AlienShipManager::Update(float timeDelta, BulletManager* bulletManager, ParticleManager* particleManager, GameStringSystem* stringBatch) { unsigned int i = 0; while (i &lt; m_alienShipList.size()) { AlienResult result = m_alienShipList[i].Update(timeDelta, bulletManager); switch (result) { case AlienResult::Dead: break; default: break; } ++i } } </code></pre> <p>in line</p> <pre><code>AlienResult result = m_alienShipList[i].Update(timeDelta, bulletManager); </code></pre> <p>There is how I add AlienShip to vector class:</p> <pre><code>m_alienShipList.push_back(AlienShip(position, speed, m_screeSize, m_alienShipTexture)); </code></pre> <p>error also appers if I chance that to:</p> <pre><code>AlienShip* newAlien = new AlienShip(position, speed, m_screeSize, m_alienShipTexture); m_alienShipList.push_back(*newAlien); delete newAlien; </code></pre> <p>but does not appear if I change that to:</p> <pre><code>AlienShip* newAlien = new AlienShip(position, speed, m_screeSize, m_alienShipTexture); m_alienShipList.push_back(*newAlien); </code></pre> <p>which hence lead to huge memory leaks.</p> <p>This is how looks my AlienShip class:</p> <pre><code>#pragma once #include "Body.h" #include "BulletManager.h" #include "ParticleManager.h" enum AliensShipState { flying, dying, dead, escaped }; enum AlienResult { No, Hit, Dying, Dead, Escaped }; class AlienShip : public Body { public: AlienShip(void); AlienShip(float2&amp; position, float2&amp; speed, float2* screenSize, ID3D11Texture2D* alienTexture); ~AlienShip(void); AlienResult Update(float timeDelta, BulletManager* bulletManager); void Draw(BasicSprites::SpriteBatch^ spriteBatch); protected: float m_baseY; AliensShipState m_state; float2* m_screenSize; }; </code></pre> <p>AlienShip class is inherited from Body class, which has Sprite class inside it, which has another vector inside it. But since Sprite class is working perfectly elsewhere, I don't think it is source of error.</p> <p>I wonder why this happens, because I can't find the relationship between deleting temporary object and corrupting vector iterator, If it corrupted at all.</p> <p>Also program compiles and runs in Release, but with some data corruption. </p> <p>I am using Visual Studio 2012 Beta for Windows 8.</p> <p>Please write if you need more source code. Unfortunately it is very hard to post all code, as this is complex program.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload