File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
addons/source-python/packages/source-python Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 9393# =============================================================================
9494# >> CLASSES
9595# =============================================================================
96- class AutoUnload ( object ) :
96+ class AutoUnload :
9797 """Class used to auto unload specific instances.
9898
9999 Each inheriting class must implement an _unload_instance method.
@@ -144,12 +144,6 @@ def _add_instance(self, caller):
144144
145145 def _unload_instance (self ):
146146 """Base _unload_instance implementation."""
147- raise NotImplementedError (
148- 'Class "{0}" from file "{1}" does not ' .format (
149- self .__class__ .__name__ , sys .modules [
150- self .__class__ .__module__ ].__file__ .split (
151- 'plugins' , 1 )[1 ][1 :]) +
152- 'have its own implementation of an _unload_instance method.' )
153147
154148
155149class WeakAutoUnload (AutoUnload ):
Original file line number Diff line number Diff line change 66# >> IMPORTS
77# =============================================================================
88# Source.Python Imports
9+ # Core
10+ from core import AutoUnload
911# Cvars
1012from _cvars import ConVar
1113from _cvars import SP_CVAR_DLL_IDENTIFIER
2830 'SP_CVAR_DLL_IDENTIFIER' ,
2931 'cvar' ,
3032 )
33+
34+
35+ # =============================================================================
36+ # >> INITIALIZATION
37+ # =============================================================================
38+ # Inject AutoUnload into ConVar's inheritance tree so that custom instances
39+ # are kept alive until the plugin creating them remains loaded.
40+ ConVar .__bases__ = (AutoUnload ,) + ConVar .__bases__
Original file line number Diff line number Diff line change 2222# =============================================================================
2323# >> CLASSES
2424# =============================================================================
25- class PublicConVar (AutoUnload , ConVar ):
25+ class PublicConVar (ConVar ):
2626 """Class used to set the notify flag on load/unload."""
2727
2828 def __init__ (
You can’t perform that action at this time.
0 commit comments