Plugin crashes MUSHclient

Posted by Poromenos on Fri 28 May 2004 10:32 PM — 8 posts, 26,738 views.

Greece #0
This plugin crashes MUSHclient 3.50, and I have no idea why.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="AutoUpdater"
   author="Poromenos"
   id="e17f476a9a92ddb464f419f3"
   language="VBscript"
   purpose="Updates plugins automatically."
   save_state="y"
   date_written="2004-05-29 01:06:58"
   requires="3.49"
   version="1.0"
   >

</plugin>
<aliases>
  <alias
   script="sbReload"
   match="test"
   enabled="y"
   sequence="100"
  >
  </alias>
</aliases>
<script>
<![CDATA[
Sub sbReload(strName, strLine, strWildcards)
    Dim lstPlugins

    lstPlugins = World.GetPluginList

    If Not IsEmpty (lstPlugins) Then

        For Each itmPlugin In lstPlugins
            If itmPlugin <> "e17f476a9a92ddb464f419f3" Then
                ReloadPlugin itmPlugin
                Note "Reloaded " & itmPlugin & " (" & GetPluginInfo (itmPlugin, 1) & ")"
            Else
                note "hi"
            End If
        Next

    End If
End Sub
]]>
</script>
</muclient>
Greece #1
It produces the error page, and if you don't click OK fast enough, it crashes. If you do click OK and it doesn't crash, it crashes when you try to remove the plugin from the plugins page, so test that too.
Australia Forum Administrator #2
OK, I didn't test reloading plugin A from plugin B, and it does indeed crash.

I have fixed that in version 3.51.

For now make an alias in the main world (not a plugin) for reloading a plugin you are working on.
Amended on Fri 28 May 2004 11:43 PM by Nick Gammon
Greece #3
It's supposed to reload all plugins on command, it's ok, i can wait for the next version... also, i added a LoadPlugin "whatever.xml" line in that plugin, and that also crashes it.
Greece #4
Also, this crashes too:
DoAfterSpecial 2, "ReloadPlugin """ & itmPlugin & """", 12
I guess it's normal, if it executes in the plugin's script space...
Amended on Fri 28 May 2004 11:48 PM by Poromenos
Australia Forum Administrator #5
I can't reproduce the DoAfterSpecial one - did you take out the other line? The DoAfterSpecial should not execute in the plugin script space.
Greece #6
Let me check again, maybe it's not it. Yes, it crashes. In the autoupdater plugin, replace the code with this:

Sub sbReload(strName, strLine, strWildcards)
    Dim lstPlugins

    lstPlugins = World.GetPluginList

    If Not IsEmpty (lstPlugins) Then

        For Each itmPlugin In lstPlugins
            DoAfterSpecial 2, "ReloadPlugin """ & itmPlugin & """", 12
        Next

    End If
End Sub


How about LoadPlugin? Does that crash too?
Australia Forum Administrator #7
I can reproduce that with 3.50 (I had the other if test in), however it seems OK with 3.51.

I haven't tested LoadPlugin from a plugin but I guess it will have the same problem. I have applied the same fix.

Basically the fix is to save the current plugin "space" during the load, and restore it afterwards, otherwise the plugin script space switches to the newly-loaded one.