Commit 4cfa9913 authored by loring's avatar loring

fix bad casts in DataNode, commit 1 of 2

* added helper methods us in As<Type> accessors that detect
  would be bad casts, where either there's no cast from one
  type to the other or the node is uninitialized. In these
  cases the cast would produce undefined behavior so an
  exception is thrown.
* fixed a bug in CurveAttributes ProcessOldVersions
  that the helpers detected.
* fixed issues in regression tests. updates to session files
  used in regression tests will be pushed in a follow up
  commit.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23793 18c085ea-50e0-402c-830e-de6fd14e8384
parent 43903430
This diff is collapsed.
......@@ -92,6 +92,10 @@ typedef enum
// Kathleen Biagas, Fri Jun 17 16:41:27 PDT 2011
// Add MapNode node.
//
// Burlen Loring, Wed Jul 16 18:38:55 PDT 2014
// Added cast helper methods to catch invalid casts that lead
// to undefined behavior
//
// ****************************************************************************
class STATE_API DataNode
......@@ -204,9 +208,20 @@ public:
int GetNumChildren() const;
int GetNumChildObjects() const;
DataNode **GetChildren();
private:
DataNode(); // not implemented
DataNode(const DataNode &); // not implemented
void operator=(const DataNode &); // not implemented
void FreeData();
// Functions to handle validation of casts from void*
// and the following conversions
template <typename RetType> RetType AsValue() const;
template <typename RetType> const RetType &AsClass(RetType &substitute) const;
template <typename RetType> const RetType *AsArray() const;
std::string Key;
NodeTypeEnum NodeType;
int Length;
......@@ -221,12 +236,11 @@ private:
static floatVector bogusFloatVector;
static doubleVector bogusDoubleVector;
static stringVector bogusStringVector;
static MapNode bogusMapNode;
};
// Utility functions.
const char *NodeTypeName(NodeTypeEnum e);
const char *NodeTypeName(int e);
NodeTypeEnum GetNodeType(const char *str);
#endif
......@@ -1922,14 +1922,14 @@ CurveAttributes::ProcessOldVersions(DataNode *parentNode,
DataNode *k = 0;
if (( k = searchNode->GetNode("renderMode")) != 0)
{
int rm = k->AsInt();
std::string mode = k->AsString();
searchNode->RemoveNode(k, true);
if (rm == 0) // asLines
if (mode == "RenderAsLines") // asLines
{
searchNode->AddNode(new DataNode("showLines", true));
searchNode->AddNode(new DataNode("pointFillMode", FillMode_ToString(CurveAttributes::Static)));
}
else
else
{
searchNode->AddNode(new DataNode("showLines", false));
searchNode->AddNode(new DataNode("pointFillMode", FillMode_ToString(CurveAttributes::Dynamic)));
......
......@@ -180,14 +180,14 @@ CurveAttributes::ProcessOldVersions(DataNode *parentNode,
DataNode *k = 0;
if (( k = searchNode->GetNode("renderMode")) != 0)
{
int rm = k->AsInt();
std::string mode = k->AsString();
searchNode->RemoveNode(k, true);
if (rm == 0) // asLines
if (mode == "RenderAsLines") // asLines
{
searchNode->AddNode(new DataNode("showLines", true));
searchNode->AddNode(new DataNode("pointFillMode", FillMode_ToString(CurveAttributes::Static)));
}
else
else
{
searchNode->AddNode(new DataNode("showLines", false));
searchNode->AddNode(new DataNode("pointFillMode", FillMode_ToString(CurveAttributes::Dynamic)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment