Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 13, 2015, 11:15:04 PM (9 years ago)
Author:
landauf
Message:

bugfix: class hierarchy wrongly considered the classes of nested members as base classes of the surrounding class. this is now fixed by using RTTI (i.e. dynamic_cast). also added some tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/class/Identifier.cc

    r9667 r10363  
    144144    /**
    145145     * @brief Initializes the parents of this Identifier while creating the class hierarchy.
    146      * @param identifiers All identifiers that were used to create an instance of this class (including this identifier itself)
     146     * @param instance The instance that was used to determine the class hierarchy of this identifier.
     147     * @param identifiers All identifiers that were used to create the instance of this class (including this identifier itself)
    147148     */
    148     void Identifier::initializeParents(const std::set<const Identifier*>& identifiers)
     149    void Identifier::initializeParents(Identifiable* instance, const std::set<const Identifier*>& identifiers)
    149150    {
    150151        if (!IdentifierManager::getInstance().isCreatingHierarchy())
     
    154155        }
    155156
     157        // Add all identifiers which are real parents (dynamic_cast is possible) and that are not equal to THIS identifier.
     158        // Checking for dynamic_cast is necessary because some classes may have other classes as nested members. This means that the Identifiers of the nested
     159        // classes are also added to the set of potential parents. The only way to distinguish them is to use RTTI (i.e. dynamic_cast).
    156160        for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it)
    157             if (*it != this)
     161            if (*it != this && (*it)->canDynamicCastObjectToIdentifierClass(instance))
    158162                this->parents_.insert(*it);
    159163    }
Note: See TracChangeset for help on using the changeset viewer.