File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
addons/source-python/packages/source-python/effects Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,20 @@ def __init__(self, temp_entity_name):
41
41
# Store the given temp entity name...
42
42
self .name = temp_entity_name
43
43
44
- # Store the function to hook...
45
- self .function = get_virtual_function (
46
- temp_entity_templates [temp_entity_name ], 'Create' )
47
-
48
44
# Set the callback to None...
49
45
self ._callback = None
50
46
47
+ try :
48
+ # Store the function to hook...
49
+ self .function = get_virtual_function (
50
+ temp_entity_templates [temp_entity_name ], 'Create' )
51
+ except NameError :
52
+ # Given name was invalid, set the function to None...
53
+ self .function = None
54
+
55
+ # Re-raise the error...
56
+ raise
57
+
51
58
def __call__ (self , callback ):
52
59
"""Store the callback and try initialize the hook."""
53
60
def _callback (stack_data , * args ):
@@ -78,6 +85,10 @@ def hook_type(self):
78
85
79
86
def _unload_instance (self ):
80
87
"""Unload the hook."""
88
+ # Was no hook registered?
89
+ if self .function is None or self ._callback is None :
90
+ return
91
+
81
92
# Unregister the hook...
82
93
self .function .remove_hook (self .hook_type , self ._callback )
83
94
You can’t perform that action at this time.
0 commit comments