Remove CPlugin's friend access to CPluginManager.

This commit is contained in:
David Anderson 2015-09-19 17:06:58 -07:00
parent 8817b4277d
commit bda9defc0f
2 changed files with 13 additions and 9 deletions

View File

@ -698,12 +698,9 @@ void CPlugin::DropEverything()
/* Other plugins could be holding weak references that were
* added by us. We need to clean all of those up now.
*/
for (List<CPlugin *>::iterator iter = g_PluginSys.m_plugins.begin();
iter != g_PluginSys.m_plugins.end();
iter++)
{
(*iter)->ToNativeOwner()->DropRefsTo(this);
}
g_PluginSys.ForEachPlugin([this] (CPlugin *other) -> void {
other->ToNativeOwner()->DropRefsTo(this);
});
/* Proceed with the rest of the necessities. */
CNativeOwner::DropEverything();
@ -2488,6 +2485,12 @@ void CPluginManager::FreePluginList(const CVector<SMPlugin *> *list)
delete const_cast<CVector<SMPlugin *> *>(list);
}
void CPluginManager::ForEachPlugin(ke::Lambda<void(CPlugin *)> callback)
{
for (auto iter = m_plugins.begin(); iter != m_plugins.end(); iter++)
callback(*iter);
}
class OldPluginAPI : public IPluginManager
{
public:

View File

@ -311,7 +311,6 @@ class CPluginManager :
public IHandleTypeDispatch,
public IRootConsoleCommand
{
friend class CPlugin;
public:
CPluginManager();
~CPluginManager();
@ -451,6 +450,10 @@ public:
void SyncMaxClients(int max_clients);
void ListPluginsToClient(CPlayer *player, const CCommand &args);
void _SetPauseState(CPlugin *pPlugin, bool pause);
void ForEachPlugin(ke::Lambda<void(CPlugin *)> callback);
private:
LoadRes LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type);
@ -488,8 +491,6 @@ private:
*/
bool FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size_t maxlength);
void _SetPauseState(CPlugin *pPlugin, bool pause);
bool ScheduleUnload(CPlugin *plugin);
void UnloadPluginImpl(CPlugin *plugin);
protected: