Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ UnloadPlugin function
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Mon 07 Mar 2011 04:57 AM (UTC) Amended on Mon 07 Mar 2011 05:00 AM (UTC) by Twisol
|
Message
| This isn't so much a feature request as it is a question. Why are there LoadPlugin() and ReloadPlugin() functions, but no complementary UnloadPlugin() function? No, I can't honestly say I have a use-case - I'm just playing with yet another wrapper interface, and its absence surprised me. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 07 Mar 2011 06:30 AM (UTC) |
Message
| Well, let's see. Plugins are supposed to be self-contained extensions. Thus plugin A shouldn't need to unload plugin B. And plugin A can't unload itself because it has the address and scripting space yanked out from under it.
In Windows for example, can Excel "unload" Word? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #2 on Mon 07 Mar 2011 07:31 AM (UTC) Amended on Mon 07 Mar 2011 07:33 AM (UTC) by Twisol
|
Message
|
Nick Gammon said: Well, let's see. Plugins are supposed to be self-contained extensions. Thus plugin A shouldn't need to unload plugin B. And plugin A can't unload itself because it has the address and scripting space yanked out from under it.
By that logic, LoadPlugin, ReloadPlugin, and even CallPlugin shouldn't exist either, as they disrupt the self-containment abstraction.
I think we've already established that plugins can depend on other plugins. The LoadPlugin documentation itself suggests the possibility of a "plugin manager" plugin. I'm simply following the logic: if you can load plugins, it seems odd that you can't do the inverse.
Nick Gammon said: In Windows for example, can Excel "unload" Word?
I'm not sure that's a fair comparison. Excel and Word are separate programs; they're not extensions to a common host.
(That said, I'm pretty sure it's possible to kill one process from another.) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #3 on Fri 06 May 2011 11:07 PM (UTC) Amended on Fri 06 May 2011 11:08 PM (UTC) by Fiendish
|
Message
| Oddly enough, I have a use case where I want a plugin to unload itself. ^_^
I suppose I'll have to settle for just disabling it. Gee, I hope I can disable a plugin from inside itself. :\ |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #4 on Sat 07 May 2011 02:08 AM (UTC) |
Message
| Actually, no, disabling it just doesn't seem like it will work out. Bummer. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sat 07 May 2011 03:08 AM (UTC) |
Message
| Why won't it work out?
Anyway, try this:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #6 on Sat 07 May 2011 03:16 AM (UTC) |
Message
| Aww, but at least give it a chance to clean up. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #7 on Sat 07 May 2011 03:20 AM (UTC) Amended on Sat 07 May 2011 03:21 AM (UTC) by Fiendish
|
Message
|
Quote: kill -9 myplugin.xml
Wait...seriously? Hahaha. I think somehow that that won't prevent it from loading the next time. Anyway I worked out a different solution. Telling users to manually remove it instead of doing it for them. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #8 on Sat 07 May 2011 04:43 PM (UTC) |
Message
|
Quote: Why won't it work out?
I had the following design goals:
1) On the very first run, ask the user if they want a task to get run every time MUSHclient loads.
2) If the user chooses "yes", then run the task in question every time MUSHclient loads.
3) If the user chooses "no", then never run the task in question.
4) Don't permanently save state about the choice in the plugin itself, because there should be a way to change the decision /without/ making the user try to remember some secret command that they will quickly forget anyway because it is something they will very very rarely use.
My initial design had this completely self-contained and would just have the plugin unload itself if the user chose "no". My second design, which violates the golden design principle (haha) of keeping plugins from interacting with each other is to have the question presented by a different plugin that optionally loads this plugin if the user chooses "yes". |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #9 on Sat 07 May 2011 10:47 PM (UTC) |
Message
| You want plugin X to load and as if the user wants to use the features in X? And if they say "no" X has to kill itself?
Is your big problem that, even if the plugin disables itself, it is still in the plugin list, and will show up again next time? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #10 on Sun 08 May 2011 02:28 AM (UTC) |
Message
| Added UnloadPlugin to version 4.73.
https://github.com/nickgammon/mushclient/commit/5072cd1e
I concede that if you can reload a plugin (which effectively deletes it for a while) you may as well be able to unload it without reloading it.
To be consistent with ReloadPlugin a plugin cannot itself. You would need to schedule an unload on a timer (which is what MUSHclient would have to do anyway to make that work). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #11 on Sun 08 May 2011 05:14 AM (UTC) Amended on Sun 08 May 2011 05:15 AM (UTC) by Fiendish
|
Message
|
Quote: Is your big problem that, even if the plugin disables itself, it is still in the plugin list, and will show up again next time? Yup. And the appropriate state variable juggling to re-disable it again on next load breaks my desire #4.
Quote: Added UnloadPlugin to version 4.73.
Cool. :) |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
34,334 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top