No Replies? :(
Ok, I will try to be more specific so you don't have to read a ton of code and just read the relevant parts.
My code was working fine when It was in this state:
https://drive.google.com/folderview?id=0B6XIrWWoN10pfkZDNDhobGZTTTU5cG5kUVNzQWE0emVtRFlUc1FKS1VEMHlVM1Z5U2RkZ3c&usp=sharing
This program has a state machine with two states – gsGame & gsMainMenu and each state has its own input handler – ghInput and initializes input commands – giCommand, which just do something when the user presses, holds or releases a key. Both states initialize a gcmdChangeState that just changes to the other state on pressing the enter key. gsGame also has a gcmdTest that just prints out “command executed” in the terminal. Both states also have their own graphics handler -ghGraphics that stores and updates graphical components – gcGraphical – gComponent. Components are initialized by each states' entity handler - ghEntity. I have created one graphical component in gsGame that is just a magenta square.
Relevant files: gcomponent.h, ghentity.h
From this point I wanted to be able to create and store gcDataModifier objects (gcDataModifier basically stores pointers to a bunch of components and has a method that loops through, updating them with new data) in ghEntity. gcDataModifier is a template class so I gave it a base (so in ghEntity I could store base pointers to them on the heap):
1 2 3 4 5
|
class gcDataModBase{
public:
gcDataModBase();
virtual ~gcDataModBase();
};
|
Then I made gcDataModifier inherit from it obviously.
At this point the program still runs fine.
Then I add to ghEntity:
|
std::vector<DataModBase*> dataModifiers_;
|
Now without even using the vector if I run my program It crashes immediately on creation of a graphical component.
And, when I step through it the vector contains 4741426 items with undefined values? I haven't even attempted to use it, why would it contain anything at all? Also, if I just put a single DataModBase pointer in ghEntity the program runs and the input commands work, but the magenta square is not there. It's like creating a pointer to DataModBase invalidates components somehow.
Also, after making the same changes again I'm getting a segfault now.
Crashing code:
https://drive.google.com/folderview?id=0B6XIrWWoN10pfm9VZHdNa3h2R0xLMjBNUmVibG5KRjlSX3JfekkwTWwzTTljMzJmRmxRNW8&usp=sharing