| 91 | } |
| 92 | |
| 93 | bool PluginManager::releasePlugin(const std::filesystem::path& path) |
| 94 | { |
| 95 | std::lock_guard<std::mutex> librariesLock(mLibrariesMutex); |
| 96 | |
| 97 | auto libraryIt = mLibraries.find(path); |
| 98 | if (libraryIt == mLibraries.end()) |
| 99 | { |
| 100 | logWarning("Failed to release plugin library {}. The library isn't loaded.", path); |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | // Get library handle. |
| 105 | SharedLibraryHandle library = libraryIt->second; |
| 106 | |
| 107 | // Delete all the classes that were owned by the library. |
| 108 | { |
| 109 | std::lock_guard<std::mutex> classDescsLock(mClassDescsMutex); |
| 110 | for (auto it = mClassDescs.begin(); it != mClassDescs.end();) |
| 111 | { |
| 112 | if (it->second->library == library) |
| 113 | it = mClassDescs.erase(it); |
| 114 | else |
| 115 | ++it; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | releaseSharedLibrary(library); |
| 120 | mLibraries.erase(libraryIt); |
| 121 | |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | void PluginManager::loadAllPlugins() |
| 126 | { |
nothing calls this directly
no test coverage detected