Skip to content

Commit

Permalink
Fix some minor bugs with vector support in the Variant class
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Nov 20, 2024
1 parent 3893211 commit 86eeff4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion avogadro/core/variant-inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ inline const Vector3& Variant::value() const
if (m_type == Vector)
return *m_value.vector;

return Vector3::Zero();
static Vector3 nullVector(0, 0, 0);
return nullVector;
}

inline void Variant::clear()
Expand All @@ -422,6 +423,9 @@ inline void Variant::clear()
} else if (m_type == Matrix) {
delete m_value.matrix;
m_value.matrix = 0;
} else if (m_type == Vector) {
delete m_value.vector;
m_value.vector = 0;
}

m_type = Null;
Expand Down Expand Up @@ -527,6 +531,8 @@ inline Variant& Variant::operator=(const Variant& variant)
m_value.string = new std::string(variant.toString());
else if (m_type == Matrix)
m_value.matrix = new MatrixX(*variant.m_value.matrix);
else if (m_type == Vector)
m_value.vector = new Vector3(*variant.m_value.vector);
else if (m_type != Null)
m_value = variant.m_value;
}
Expand Down

0 comments on commit 86eeff4

Please sign in to comment.