Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6601915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:48:52+00:00 2026-05-25T18:48:52+00:00

I’m getting a strange crash when I try to interact with a map in

  • 0

I’m getting a strange crash when I try to interact with a map in this particular class. When I try to call clear() or even begin() on the map it crashes. I haven’t added anything to map, at this point nothing has touched it at all.

Code in question:

spriteMap_.clear();
if (!spriteMap_.empty())
{
    SpriteMap::const_iterator end = spriteMap_.end();
    for (SpriteMap::const_iterator it = spriteMap_.begin(); it != end; ++it)
    {
        it->second->draw(screen);
    }
}

Even stranger is that this is not unique to the map but to any maps in this particular class. I have another map, that is also not being touched until here (I tested it with a clear call in this function).

When I use intelli-sense on the maps both show themselves with tons of values already in them and the empty() call returns false. Similarily, size() returns a non-zero result.

Info:
I’m compiling in Visual Studios 2010 and linking against SDL.

Any help is appreciate.

Edit (more info):

My header has this line:


private:
std::map spriteMap_;

And the only code that is hit is the function I showed you. I have other code but the break point on the function is never hit (I don’t call that function).

But here it is:

Sprite* SpriteManager::createSprite(std::string fileName)
{
   ...

   Sprite* newSprite = &Sprite(nextSpriteId_, this, image);
   nextSpriteId_++;
   spriteMap_[newSprite->id_] = newSprite;
   return newSprite;
}

Fixed:

Moral of the story is don’t ever do something like this:

ObjPtr* objPtr = &Obj();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:48:53+00:00Added an answer on May 25, 2026 at 6:48 pm

    You are probably corrupting the map´s memory somewhere within that class. Get the map memory address, and see what happens when you attach breakpoints to such locations.

    Edit:

    Sprite* newSprite = &Sprite(nextSpriteId_, this, image);

    Here you are taking a pointer to a temporary object; note that is not even legal C++ but a nasty MSVC language extension. Right after you take a pointer to it, the temporary Sprite object is destroyed and you are left with an invalid pointer. You then derreference that pointer to get the id -which works just by chance here-, and then add that invalid pointer to the map. That´s at least one of the problems, it may or may not be related to your crash, there may be more problems out there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.