views:

18

answers:

1

Okay, so long weekend away with Macbook I started making an asset loader for 2D game platforms, its working fine in xcode, but when I got home and tried and load it up on Windows I get a debug error.

Essentially what is happening is that the first call to the iterator works? the second doesn't, but only on the second attempt at calling the second one will it cause the error (this is in a game loop). I've swapped the calls but the same result happens.

The program (in debug) quits and gives me the message

AssetLoadingWin.exe has triggered a breakpoint

then points to the following code in dbgrptt.c

#undef _CrtDbgBreak

/* These methods don't need a separate
   wchar version. Hence they need to be compiled only once from
   the original file */

_CRTIMP void _cdecl _CrtDbgBreak(
    void
    )
{
    DebugBreak(); // <-- breakpoint here
}

if I let it continue i get the following message

Microsoft Visual Studio C Runtime Library has detected a fatal error in AssetLoadingWin.exe.

Press Break to debug the program or Continue to terminate the program.

which in turn points to the code in dbghook.c

__declspec(noinline)
void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved)
{
    /* assign 0 to _debugger_hook_dummy so that the function is not folded in retail */
    (_Reserved);
    _debugger_hook_dummy = 0;
}

After alot of breakpoints Its been narrowed down to an iterator calling a method.

// line 347 in the pastie.
void libImageDraw(GraphicIt &gfxIt, GraphicOptions &opts) {
    gfxIt->second->draw(opts.x, opts.y, opts.z); line
}

Thanks for any pointers.

Full Source Code

window.cpp

asset_manager.hpp

A: 

It looks like you don't check the result of the find call on line 239 in the drawGraphic function.

Also i think the loadAll loop looks dodgy. You're looping over m_assetsToLoad and modifying it at the same time in loadResource.

ngoozeff
ah thanks, erasing the loop at the end worked.
PhilCK