SFML community forums

Help => General => Topic started by: Anand on March 19, 2016, 08:34:43 am

Title: error-debug assertion failed
Post by: Anand on March 19, 2016, 08:34:43 am
i use visual studio 2015. i am creating a class textureholder to load and access the textures in sprite using std::map and on building the project gives debug assertion failed error. i have copied the image in the folder of the project.
i have attached the snapshot of the code , error, the folder of the project which i am doing.
please help me out
Title: AW: error-debug assertion failed
Post by: eXpl0it3r on March 19, 2016, 09:01:31 am
If you click retry the debugger would step in and pause the execution. Then you'd know exactly where the error happened and get a full stack trace.

The assertion also pretty much explains what's going on. You're trying to dereference a map iterator. Since there's only one dereference operator, I assume that's where error happens.

return *found->second;

Maybe that should be
return *(found->second)
Title: Re: error-debug assertion failed
Post by: Anand on March 19, 2016, 02:08:51 pm
sorry sir but the same error message appears after the modification which you have suggested.
help furthure
Title: Re: error-debug assertion failed
Post by: Laurent on March 19, 2016, 02:59:27 pm
You load the airplaine texture, and then use the scene texture. Since it's not loaded, it can't be found in the map and the iterator that you get after the call to "find" is invalid, thus it can't be dereferenced.

When you hit an assertion, you can break and use the debugger to walk back the call stack, and watch variables and function arguments to find out what's wrong in your code.
Title: Re: error-debug assertion failed
Post by: Anand on March 19, 2016, 07:36:01 pm
thank you sir. it now works