Skip to content

Changed AutoUnload to be able to manage objects generated from custom packages. #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

CookStar
Copy link
Contributor

@CookStar CookStar commented Dec 2, 2020

This ensures the code that generates objects that expect unload in the custom packages works correctly.

# addons/source-python/packages/custom/test/__init__.py

# Source.Python Imports
#   Core
from core import AutoUnload

class Test(AutoUnload):
    def __init__(self):
        print("init Test")
    def _unload_instance(self):
        print("unloaded Test")

def test():
    return Test()
# addons/source-python/plugins/test_plugin/test_plugin.py

from test import Test
from test import test

Test()
test()

Output:

sp plugin load test_plugin
[SP] Loading plugin 'test_plugin'...
init Test
init Test
[SP] Successfully loaded plugin 'test_plugin'.
sp plugin unload test_plugin
[SP] Unloading plugin 'test_plugin'...
unloaded Test
unloaded Test
[SP] Successfully unloaded plugin 'test_plugin'.

@Ayuto
Copy link
Member

Ayuto commented Dec 11, 2020

Thank you, that works very well!

@Ayuto Ayuto merged commit 6722989 into Source-Python-Dev-Team:master Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants