Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2015, 12:12:20 AM (9 years ago)
Author:
landauf
Message:

unload in reversed order

Location:
code/branches/core7/src/libraries/core/module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/module/ModuleInstance.cc

    r10535 r10536  
    6565    void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticInitialization::Type type)
    6666    {
     67        // unload in reversed order
    6768        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
    68         for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
     69        for (std::set<StaticallyInitializedInstance*>::reverse_iterator it = instances.rbegin(); it != instances.rend(); ++it)
    6970            (*it)->unload();
    7071    }
  • code/branches/core7/src/libraries/core/module/StaticInitializationManager.cc

    r10532 r10536  
    5151    void StaticInitializationManager::loadModule(ModuleInstance* module)
    5252    {
     53        // attention: loading a module may add new handlers to the list
    5354        for (std::list<StaticInitializationHandler*>::iterator it = this->handlers_.begin(); it != this->handlers_.end(); ++it)
    5455            (*it)->loadModule(module);
     
    5758    void StaticInitializationManager::unloadModule(ModuleInstance* module)
    5859    {
    59         for (std::list<StaticInitializationHandler*>::iterator it = this->handlers_.begin(); it != this->handlers_.end(); ++it)
    60             (*it)->unloadModule(module);
     60        // unload in reversed order
     61        // attention: unloading a module may remove handlers from the list
     62        for (std::list<StaticInitializationHandler*>::reverse_iterator it = this->handlers_.rbegin(); it != this->handlers_.rend(); )
     63            (*(it++))->unloadModule(module);
    6164    }
    6265}
Note: See TracChangeset for help on using the changeset viewer.