[Orxonox-commit 1684] r6402 - code/branches/presentation2/src/libraries/core
rgrieder at orxonox.net
rgrieder at orxonox.net
Tue Dec 22 22:49:25 CET 2009
Author: rgrieder
Date: 2009-12-22 22:49:25 +0100 (Tue, 22 Dec 2009)
New Revision: 6402
Modified:
code/branches/presentation2/src/libraries/core/ClassTreeMask.cc
Log:
Protected ClassTreeMask functions against NULL identifiers.
That can happen for instance in the following situation:
this->targetMask_.exclude(ClassByString("MyClass"));
If MyClass doesn't exist you shouldn't get a segfault anymore.
Modified: code/branches/presentation2/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/ClassTreeMask.cc 2009-12-22 21:38:34 UTC (rev 6401)
+++ code/branches/presentation2/src/libraries/core/ClassTreeMask.cc 2009-12-22 21:49:25 UTC (rev 6402)
@@ -290,6 +290,8 @@
*/
void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean)
{
+ if (!subclass)
+ return;
// Check if the given subclass is a child of our root-class
if (subclass->isA(this->root_->getClass()))
{
@@ -319,6 +321,8 @@
*/
void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite)
{
+ if (!subclass)
+ return;
// Check if the current node contains exactly the subclass we want to add
if (subclass == node->getClass())
{
@@ -394,6 +398,8 @@
*/
void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean)
{
+ if (!subclass)
+ return;
for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
this->add(*it, this->isIncluded(*it), false, false);
@@ -427,6 +433,8 @@
*/
bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const
{
+ if (!subclass)
+ return false;
// Check if the searched subclass is of the same type as the class in the current node or a derivative
if (subclass->isA(node->getClass()))
{
More information about the Orxonox-commit
mailing list