Sign in to follow this  
  • entries
    42
  • comments
    85
  • views
    46485

GUI, heap corruption

Sign in to follow this  

240 views

Progress for the GUI Editor has been slow. I've been trying to figure out a way to have special gui panel to dynamically display all the properties for the element that's being edited, and provide widgets to adjust these properties. I'm unsuccessful so far, resorting to adding widgets for the common properties of all widgets, and a switch statement for the unique properties of each class. This isn't extensible, so I guess I'll dig through some design patterns for some insight. So far you can edit the tag, caption, color, and texture of any widget. Gamedev gives me an error when I try to upload images, so there are none this time. They're not exactly impressive anyway.

I had the fun of finding the source of a heap corruption! It crashed when I reloaded the test level from the menu the second or third time. I have little(no) experience with heap corruptions, so I thought this was because I deallocated the level improperly. I checked everything well, and decided to blame my physics library, because it was a physics class being allocated with it's own custom allocator. When that leads to no answers, I desperately comment out everything and begin adding parts of code back to the build. The offending code seemed to be the Entity creation. I naturally search my Entity code, not knowing what to look for.

Finally I research a little about heap corruptions, and stumble upon _CrtSetDbgFlag() and other magical heap debugging functions. They directed me to where I allocate a GUI class in the game object. This is NOWHERE NEAR the intial crash in any way. The source of the problem turned out to be the misuse of my own GUI class. I have GUI elements, panels, and systems. Elements are managed by panels, that are managed by a system. I attempted to add a Panel subclass into the GUI system explicitly, which somehow corrupted the heap. I still don't know exactly why this happened, so its a little unnerving. In the end I used a separate GUI system for the special Panel with no problems. I think I'm going to experiment to see if I can find out the cause.
Sign in to follow this  


1 Comment


Recommended Comments

Quote:
Original post by sneakyrobot
I've been trying to figure out a way to have special gui panel to dynamically display all the properties for the element that's being edited, and provide widgets to adjust these properties.
Something like the .NET PropertyGrid control? That uses reflection to inspect properties and is controllable via attributes to give fine control over any .NET object's properties - maybe it could give you some ideas?

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now