(I've never asked a question here before so please excuse me if I don't follow proper etiquette)
I'm working on a scene graph for use in a GLWidget, and I'm running into a weird case of bad_alloc. Each node (called a graphNode) in my scene graph has the following fields:
QString* name
graphNode* parent
std::vector<graphNode*> children
myPolygon* polygon
(myPolygon is a custom polygon class I created to store vertex and color data)
My SceneGraph class has the following fields:
graphNode* root
std::vector<graphNode*> allNodes
std::vector<myPolygon> allShapes
the bad_alloc occurs when I'm trying to build allNodes. my root ndoe has 5 children, and if I use std::cout to print the size of the children vector I do get 5. However, when I try to push each child to allNodes I get a std::bad_alloc error. The exact Application ouput in QT is
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
I'm not sure what I'm doing wrong, especially since the program is recognizing that the children exist (and when I step through using print statements and the debugger I can see that the children are all what I expect them to be. Any help would be greatly appreciated, and if I need to provide my code I would be more than glad to do so.
EDIT: Since someone asked, essentially I have some code that creates a character as follows:
Node Root: name "root" polygon = a rectangle for the torso graphNode* parent = NULL vector of 5 children [Head, Arm1, Arm2, Leg1, Leg2]
Node Head: name "head" polygon = a circle for the head graphNode* parent = root an empty children vector
Node Arm1 name "arm1" polygon = a rectangle for the upper arm graphNode* parent = root vector of 1 child [Forearm1]
Node Arm2 name "arm2" polygon = a rectangle for the upper arm graphNode* parent = root vector of 1 child [Forearm2]
Node Leg1 name "leg1" polygon = a rectangle for the thigh graphNode* parent = root vector of 1 child [Loweleg1]
Node Leg2 name "leg2" polygon = a rectangle for the thigh graphNode* parent = root vector of 1 child [Loweleg2]
Node Forearm1 name "forearm1" polygon = a rectangle for the forearm graphNode* parent = Arm1 an empty children vector
Node Forearm2 name "forearm2" polygon = a rectangle for the forearm graphNode* parent = Arm2 an empty children vector
Node Lowerleg1 name "lowerleg1" polygon = a rectangle for the calf graphNode* parent = Leg1 an empty children vector
Node Lowerleg2 name "lowerleg2" polygon = a rectangle for the calf graphNode* parent = Leg2 an empty children vector