File tree 3 files changed +12
-8
lines changed
addons/source-python/packages/source-python
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 93
93
# =============================================================================
94
94
# >> CLASSES
95
95
# =============================================================================
96
- class AutoUnload ( object ) :
96
+ class AutoUnload :
97
97
"""Class used to auto unload specific instances.
98
98
99
99
Each inheriting class must implement an _unload_instance method.
@@ -144,12 +144,6 @@ def _add_instance(self, caller):
144
144
145
145
def _unload_instance (self ):
146
146
"""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.' )
153
147
154
148
155
149
class WeakAutoUnload (AutoUnload ):
Original file line number Diff line number Diff line change 6
6
# >> IMPORTS
7
7
# =============================================================================
8
8
# Source.Python Imports
9
+ # Core
10
+ from core import AutoUnload
9
11
# Cvars
10
12
from _cvars import ConVar
11
13
from _cvars import SP_CVAR_DLL_IDENTIFIER
28
30
'SP_CVAR_DLL_IDENTIFIER' ,
29
31
'cvar' ,
30
32
)
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 22
22
# =============================================================================
23
23
# >> CLASSES
24
24
# =============================================================================
25
- class PublicConVar (AutoUnload , ConVar ):
25
+ class PublicConVar (ConVar ):
26
26
"""Class used to set the notify flag on load/unload."""
27
27
28
28
def __init__ (
You can’t perform that action at this time.
0 commit comments