diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 0670c17f..41bdcb4c 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,6 @@ * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or . - * - * Version: $Id$ */ #include "ConVarManager.h" @@ -96,6 +94,8 @@ void ConVarManager::OnSourceModAllInitialized() SH_ADD_HOOK_STATICFUNC(ICvar, CallGlobalChangeCallbacks, icvar, OnConVarChanged, false); + g_PluginSys.AddPluginsListener(this); + /* Add the 'convars' option to the 'sm' console command */ g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); } @@ -162,6 +162,8 @@ void ConVarManager::OnSourceModShutdown() /* Remove the 'convars' option from the 'sm' console command */ g_RootMenu.RemoveRootConsoleCommand("cvars", this); + g_PluginSys.RemovePluginsListener(this); + /* Remove the 'ConVar' handle type */ g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent); } @@ -252,12 +254,23 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na void ConVarManager::OnPluginUnloaded(IPlugin *plugin) { ConVarList *pConVarList; + List::iterator iter; /* If plugin has a convar list, free its memory */ if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true)) { delete pConVarList; } + + /* Remove convar queries for this plugin that haven't returned results yet */ + for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++) + { + ConVarQuery &query = (*iter); + if (query.pCallback->GetParentRuntime() == plugin->GetRuntime()) + { + m_ConVarQueries.erase(iter); + } + } } void ConVarManager::OnHandleDestroy(HandleType_t type, void *object) diff --git a/public/sourcepawn/sp_vm_api.h b/public/sourcepawn/sp_vm_api.h index 65e7fa3f..14303256 100644 --- a/public/sourcepawn/sp_vm_api.h +++ b/public/sourcepawn/sp_vm_api.h @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourcePawn - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,6 @@ * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or . - * - * Version: $Id$ */ #ifndef _INCLUDE_SOURCEPAWN_VM_API_H_ @@ -61,6 +59,7 @@ typedef struct sp_context_s sp_context_t; namespace SourcePawn { class IVirtualMachine; + class IPluginRuntime; /* Parameter flags */ #define SM_PARAM_COPYBACK (1<<0) /**< Copy an array/reference back after call */ @@ -260,6 +259,13 @@ namespace SourcePawn const cell_t *params, unsigned int num_params, cell_t *result) =0; + + /** + * @brief Returns parent plugin's runtime + * + * @return IPluginRuntime pointer. + */ + virtual IPluginRuntime *GetParentRuntime() =0; }; diff --git a/sourcepawn/jit/sp_vm_function.cpp b/sourcepawn/jit/sp_vm_function.cpp index 07dfab91..15c117b0 100644 --- a/sourcepawn/jit/sp_vm_function.cpp +++ b/sourcepawn/jit/sp_vm_function.cpp @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourcePawn - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,6 @@ * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or . - * - * Version: $Id$ */ #include @@ -332,6 +330,11 @@ int CFunction::Execute2(IPluginContext *ctx, cell_t *result) return err; } +IPluginRuntime *CFunction::GetParentRuntime() +{ + return m_pRuntime; +} + funcid_t CFunction::GetFunctionID() { return m_FnId; diff --git a/sourcepawn/jit/sp_vm_function.h b/sourcepawn/jit/sp_vm_function.h index 0969aa22..48131b8b 100644 --- a/sourcepawn/jit/sp_vm_function.h +++ b/sourcepawn/jit/sp_vm_function.h @@ -1,8 +1,8 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourcePawn - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,6 @@ * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or . - * - * Version: $Id$ */ #ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_ @@ -82,6 +80,7 @@ public: const cell_t *params, unsigned int num_params, cell_t *result); + IPluginRuntime *GetParentRuntime(); public: void Set(BaseRuntime *runtime, funcid_t fnid, uint32_t pub_id); private: