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

View File

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