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