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 - Lignum

Pages: 1 [2]
16
General / Re: Enable user to open file
« on: January 21, 2014, 09:33:12 pm »
SFML can't do this as far as I know. However, on Windows you can use the Windows API to get what you want. The only downside is that it's not portable.

17
General / Re: Resource Manager Stack Corruption
« on: January 21, 2014, 06:15:54 pm »
remove throw from your code, it should work
and, p must not optimized, it isn't normal
Of course it will work, but it will merely hide the issue rather than actually fix it. Besides, that's Microsoft's code, not mine.

I've fixed that issue already, if you've seen my last post.

18
General / Re: Resource Manager Stack Corruption
« on: January 21, 2014, 05:27:21 pm »
After having the resource map store std::unique_ptrs rather than actual objects, everything works as expected.
However when making a manager for sf::Fonts the program will trigger a breakpoint on
Code: [Select]
msvcr120d.dll!_CrtIsValidHeapPointer(const void * pUserData) Line 2034
when my program exits.

I do believe that this is a problem on SFML's side, because this code reproduces the error:
sf::Font* font = new sf::Font;
font->loadFromFile("Fonts/arial.ttf");
delete font;

EDIT: http://en.sfml-dev.org/forums/index.php?topic=10191.5 this guy is in the exact same situation.

19
General / Re: Resource Manager Stack Corruption
« on: January 21, 2014, 03:33:45 pm »
Thanks for your reply, however, even though I have fiddled with the Runtime Library setting in the past they do match for both, the .exe and .dll, as do the Release and Debug configurations. So that's most likely not the problem.

Since the Resource Manager is not the only thing in my .dll (it's an entire game engine), I cannot go header only. Unfortunately making it an unacceptable solution.

--------------------------------------------------------------------------

I don't know whether this helps but when building with the release configuration I get an Acess Violation in new.cpp on line 62:


void *__CRTDECL operator new(size_t size) _THROW1(_STD bad_alloc)
        {       // try to allocate size bytes
        void *p;
        while ((p = malloc(size)) == 0)
                if (_callnewh(size) == 0)
                {       // report no memory
                        _THROW_NCEE(_XSTD bad_alloc, ); // <- Access violation is thrown here.
                }

        return (p);
        }

The debugger says that 'size' and 'p' were optimized away, is this normal?

The code above makes me think that I've reached the stack's maximum capacity, which is unlikely because 'new' doesn't have anything to do with the stack.

EDIT: The issue doesn't seem to occur when there's no resources to load.

20
General / [Solved] Resource Manager Stack Corruption
« on: January 21, 2014, 12:17:19 pm »
I am currently attempting to write a resource manager for SFML to make my life easier. Ironically, it made my life harder. After having had two different managers, for fonts and textures, I decided to switch over to making a general manager that uses templates. This, however did not work out as expected.

I have submitted the entire class on pastebin: http://pastebin.com/ggynEjXP

Using this class causes the stack to corrupt around either the variable "line" or "tempResource" (seems to be random?) in the "LoadCollection" function. What weirds me out is that Visual Studio breaks on the closing bracket of the function and the call stack says the function "GetResource" leads to the corruption of both of these variables, when it doesn't even contain them.

This code snippet, that uses the manager, seems to be triggering the issue:

...
game->client->fontManager.LoadCollection("Error");
errorTextLn1.setFont(*game->client->fontManager.GetResource("arial.ttf")); // <-- Call stack refers to this.
...
 

Any help would be vastly appreciated since I'm sitting in an error storm, which is not too much of a nice experience. Thanks in advance.

Pages: 1 [2]