| 833 | //----------------------------------------------------------------------------- |
| 834 | |
| 835 | bool 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() ); |
no test coverage detected