this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CoreServices: Unload Component when all instances are gone

+19 -3
+18 -2
src/frameworks/CoreServices/ComponentManager.cpp
··· 476 476 if (!cd->entryPoint) 477 477 return invalidComponentID; 478 478 479 - // Releasing the bundle triggers CFBundleUnloadExecutable(), 480 - // so we leak the bundle instance here. 479 + cd->loadedBundle = bundle; 481 480 } 482 481 483 482 ComponentInstanceData cid; ··· 528 527 cp.params[0] = uintptr_t(c); 529 528 530 529 OSStatus status = dispatch(&cp); 530 + 531 + Component component = it->second.component; 532 + auto itMap = m_componentsMap.find(component); 533 + if (itMap != m_componentsMap.end()) 534 + { 535 + ComponentData* cd = itMap->second; 536 + cd->instances--; 537 + 538 + // If this was a dynamically loaded component 539 + // and there are not instances left, release the bundle. 540 + if (cd->instances == 0 && cd->loadedBundle) 541 + { 542 + cd->entryPoint = nullptr; 543 + CFRelease(cd->loadedBundle); 544 + cd->loadedBundle = nullptr; 545 + } 546 + } 531 547 532 548 m_componentInstances.erase(it); 533 549 return status;
+1 -1
src/frameworks/CoreServices/ComponentManager.h
··· 72 72 private: 73 73 struct ComponentData 74 74 { 75 - // Assigned identifier 76 75 Component component; 77 76 78 77 ComponentDescription cd; ··· 80 79 std::string name, info; 81 80 82 81 std::string bundlePath, entryPointName; 82 + CFBundleRef loadedBundle = nullptr; 83 83 84 84 uint32_t instances; 85 85 };