MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / unloadModuleExplicit

Method unloadModuleExplicit

Engine/source/module/moduleManager.cpp:835–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833//-----------------------------------------------------------------------------
834
835bool ModuleManager::unloadModuleExplicit( const char* pModuleId )
836{
837 // Lock database.
838 LockDatabase( this );
839
840 // Sanity!
841 AssertFatal( pModuleId != NULL, "Cannot unload explicit module Id with NULL module Id." );
842
843 typeModuleLoadEntryVector moduleResolvingQueue;
844 typeModuleLoadEntryVector moduleReadyQueue;
845
846 // Fetch module Id.
847 StringTableEntry moduleId = StringTable->insert( pModuleId );
848
849 // Fetch modules definitions.
850 ModuleDefinitionEntry* pDefinitions = findModuleId( moduleId );
851
852 // Did we find the module Id?
853 if ( pDefinitions == NULL )
854 {
855 // No, so warn.
856 Con::warnf( "Module Manager: Cannot unload explicit module Id '%s' as it does not exist.", moduleId );
857 return false;
858 }
859
860 // Find if the module is actually loaded.
861 ModuleDefinition* pLoadedModule = findLoadedModule( moduleId );
862
863 // Is the module loaded?
864 if ( pLoadedModule == NULL )
865 {
866 // No, so warn.
867 Con::warnf( "Module Manager: Cannot unload explicit module Id '%s' as it is not loaded.", moduleId );
868 return false;
869 }
870
871 // Fetch module group.
872 StringTableEntry moduleGroup = pDefinitions->mModuleGroup;
873
874 // Info.
875 if ( mEchoInfo )
876 {
877 Con::printSeparator();
878 Con::printf( "Module Manager: Unloading explicit module Id '%s':" , moduleId );
879 }
880
881 // Finish if we could not resolve the dependencies for module Id (of any version Id).
882 if ( !resolveModuleDependencies( moduleId, pLoadedModule->getVersionId(), moduleGroup, false, moduleResolvingQueue, moduleReadyQueue ) )
883 return false;
884
885 // Check the modules we want to unload to ensure that we do not have incompatible modules loaded already.
886 for ( typeModuleLoadEntryVector::iterator moduleReadyItr = moduleReadyQueue.begin(); moduleReadyItr != moduleReadyQueue.end(); ++moduleReadyItr )
887 {
888 // Fetch load ready module definition.
889 ModuleDefinition* pLoadReadyModuleDefinition = moduleReadyItr->mpModuleDefinition;;
890
891 // Fetch the module Id loaded entry.
892 ModuleLoadEntry* pLoadedModuleEntry = findModuleLoaded( pLoadReadyModuleDefinition->getModuleId() );

Callers 1

Calls 15

LockDatabaseClass · 0.85
printSeparatorFunction · 0.85
printfFunction · 0.85
executefFunction · 0.85
removePathExpandoFunction · 0.85
getVersionIdMethod · 0.80
getModuleIdMethod · 0.80
reduceLoadCountMethod · 0.80
getLoadCountMethod · 0.80
erase_fastMethod · 0.80
getDestroyFunctionMethod · 0.80
deleteAllObjectsMethod · 0.80

Tested by

no test coverage detected