• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualSuperVGA

Posted 26 June 2013 - 10:19 PM

Hi guys, I wanted to post a response ~8 hours ago, when GD was having issues, but I'll read Eight and Triencos reply as soon as I get the time.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

The first one. (Well, it's within another static function). Actually, I thought I was being clever with omitting that part:
I have a static function in SceneElement called SceneElement* SceneElement::Parse(). It's one of those times where I create on the heap:

    SceneElement* SceneElement::parse(const std::string &source_path, const pugi::xml_node &node)
{
bool visible = utility::string_to_bool( node.attribute("visible").as_string("true"), true);
std::string name = node.attribute("name").as_string("Unnamed element");
SceneElement* resulting_element = new SceneElement(name, visible);

pugi::xml_node size_child = node.child("size");
if(!size_child.empty())
{
}

pugi::xml_node offset_point_child = node.child("offset_point");
if(!offset_point_child.empty())
{
}

pugi::xml_node offset_child = node.child("offset");
if(!offset_child.empty())
{
}

pugi::xml_node scale_child = node.child("scale"); /* add pixel scaling option/value or granularity value + support for descendance */
if(!scale_child.empty())
{
}

return resulting_element;
}


This function is called from Grid* Grid::parse(), where Grid : public SceneElement
It behaves in the same way.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

Thanks, Elci. I'll read that now. I've got Cline at al's book, -I love how he describes best practices on parashift. Much appreciated.

Even if it looks like I've done something obviously wrong, I'd really appreciate if you'll further with feedback, in case I just don't get it.
But I'll read the parashift page.... I had no idea that "static initialization order fiasco" was a thing...

### #2SuperVGA

Posted 26 June 2013 - 10:18 PM

Hi guys, I wanted to post a response ~8 hours ago, when GD was having issues, but I'll read Eight and Triencos reply as soon as I get the time.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

Yes, I am. Actually, I thought I was being clever with omitting that part:
I have a static function in SceneElement called SceneElement* SceneElement::Parse(). It's one of those times where I create on the heap:

    SceneElement* SceneElement::parse(const std::string &source_path, const pugi::xml_node &node)
{
bool visible = utility::string_to_bool( node.attribute("visible").as_string("true"), true);
std::string name = node.attribute("name").as_string("Unnamed element");
SceneElement* resulting_element = new SceneElement(name, visible);

pugi::xml_node size_child = node.child("size");
if(!size_child.empty())
{
}

pugi::xml_node offset_point_child = node.child("offset_point");
if(!offset_point_child.empty())
{
}

pugi::xml_node offset_child = node.child("offset");
if(!offset_child.empty())
{
}

pugi::xml_node scale_child = node.child("scale"); /* add pixel scaling option/value or granularity value + support for descendance */
if(!scale_child.empty())
{
}

return resulting_element;
}


This function is called from Grid* Grid::parse(), where Grid : public SceneElement
It behaves in the same way.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

Thanks, Elci. I'll read that now. I've got Cline at al's book, -I love how he describes best practices on parashift. Much appreciated.

Even if it looks like I've done something obviously wrong, I'd really appreciate if you'll further with feedback, in case I just don't get it.
But I'll read the parashift page.... I had no idea that "static initialization order fiasco" was a thing...

### #1SuperVGA

Posted 26 June 2013 - 10:17 PM

Hi guys, I wanted to post a response ~8 hours ago, when GD was having issues, but I'll read Eight and Triencos reply as soon as I get the time.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

Yes, I am. Actually, I thought I was being clever with omitting that part:
I have a static function in SceneElement called SceneElement* SceneElement::Parse(). It's one of those times where I create on the heap:

    SceneElement* SceneElement::parse(const std::string &source_path, const pugi::xml_node &node)
{
bool visible = utility::string_to_bool( node.attribute("visible").as_string("true"), true);
std::string name = node.attribute("name").as_string("Unnamed element");
SceneElement* resulting_element = new SceneElement(name, visible);

pugi::xml_node size_child = node.child("size");
if(!size_child.empty())
{
}

pugi::xml_node offset_point_child = node.child("offset_point");
if(!offset_point_child.empty())
{
}

pugi::xml_node offset_child = node.child("offset");
if(!offset_child.empty())
{
}

pugi::xml_node scale_child = node.child("scale"); /* add pixel scaling option/value or granularity value + support for descendance */
if(!scale_child.empty())
{
}

return resulting_element;
}


This function is called from Grid* Grid::parse(), where Grid : public SceneElement
It behaves in the same way.

Are you creating a SceneElement object, or an object that in turn creates a SceneElement object, statically anywhere? In that case, that object may be constructed before the map constructors, and thus the SceneElement constructor is accessing a not-yet-constructed map object.

Thanks, Elci. I'll read that now. I've got Cline at al's book, -I love how he describes best practices on parashift. Much appreciated.

Even if it looks like I've done something obviously wrong, I'd really appreciate if you'll further with feedback, in case I just don't get it.
But I'll read the parashift page.... I had no idea that "static initialization order fiasco" was a thing...

PARTNERS