Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - CoconutFred

Pages: [1]
1
Hey all, whenever I run my game, the application crashes immediately without entering main(). On debugging, I get an error:

Unhandled exception at 0x55E76001 (sfml-graphics-d-2.dll) in DungeonRaider.exe:
0xC0000005: Access violation reading location 0x00000000.

The offending code is in my Animation class's assignment operator.

The Animation class consists of a dynamic array of sf::Sprite objects. When the assignment operator executes, the sf::Sprite objects from the source Animation object are copied by value to the new Animation object, like such:

Animation& operator=(const Animation& srcAnimation) const
{
    //sprite_ is the dynamic array of sf::Sprite objects

    /*...code to delete the elements of the old array and make space for the new one...*/

    sprites_ = new sf::Sprite[/*...the new number of sprites...*/];
    for(int i=0;i</*...the new number of sprites...*/;i++)
    {
        sprites_[i].setTexture(*(srcAnimation.sprites_[i].getTexture())); //<----This is the line that debugging stops at
    }
}
 



I've checked that I'm linking debug libraries for debug mode.

This is the call stack:

        sfml-graphics-d-2.dll!55e76001()        Unknown
        [Frames below may be incorrect and/or missing, no symbols loaded for sfml-graphics-d-2.dll]    
        sfml-graphics-d-2.dll!55e8155d()        Unknown
>       DungeonRaider.exe!Animation::operator=(const Animation & srcAnimation) Line 110 C++
        DungeonRaider.exe!AnimState::AnimState() Line 24        C++
        DungeonRaider.exe!AnimStateController::AnimStateController() Line 27    C++
        DungeonRaider.exe!`dynamic initializer for 'AnimStateComponent::s_defaultController''() Line 55 C++
        [External Code]


Any ideas? I'm not quite sure where to start... :-\

Also, any suggestions for my Animation class? I feel like I should be using std::vector instead of a dynamic array of sprites.


EDIT: Maybe this should've been in the graphics section. Can someone move this?

EDIT 2: Arrghh! It's a null pointer. But why is it crashing before main() starts?

Pages: [1]