- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc
r10624 r10821 99 99 std::set<Identifier*> identifiers; 100 100 const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER); 101 for ( std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)102 identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>( *it)->getIdentifier());101 for (const auto & instance : instances) 102 identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(instance)->getIdentifier()); 103 103 104 104 // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is … … 106 106 // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another 107 107 // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash. 108 for ( std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)109 ( *it)->destroyObjects();108 for (const auto & identifier : identifiers) 109 (identifier)->destroyObjects(); 110 110 111 111 // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another 112 112 // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by 113 113 // changing object dependencies; or by changing the logic that allows modules to be unloaded). 114 for ( std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)114 for (const auto & identifier : identifiers) 115 115 { 116 ObjectListBase* objectList = Context::getRootContext()->getObjectList( *it);116 ObjectListBase* objectList = Context::getRootContext()->getObjectList(identifier); 117 117 if (objectList->size() > 0) 118 118 { 119 orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << ( *it)->getName()119 orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (identifier)->getName() 120 120 << " after unloading the Identifier. This may lead to a crash" << endl; 121 121 } … … 123 123 124 124 // destroy object-lists in all contexts 125 for ( std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)125 for (const auto & identifier : identifiers) 126 126 { 127 127 // only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over 128 if (!( *it_identifier)->isExactlyA(Class(Context)))128 if (!(identifier)->isExactlyA(Class(Context))) 129 129 { 130 130 // iterate over all contexts 131 131 for (ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context) 132 it_context->destroyObjectList(( *it_identifier));132 it_context->destroyObjectList((identifier)); 133 133 } 134 134 }
Note: See TracChangeset
for help on using the changeset viewer.