Register forum user name Search FAQ

Gammon Forum

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 ➜ Bug reports ➜ Miniwindows not deleting as intended

Miniwindows not deleting as intended

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by LezChap   (36 posts)  Bio
Date Sat 28 May 2011 08:27 PM (UTC)
Message
A change in version 4.73 has caused the behavior of two of my plugins which use multiple miniwindows in the same location to behave differently. It appears as though a miniwindow is not deleting as intended.

The simpler plugin which is behaving oddly is as follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, February 21, 2010, 8:40 PM -->
<!-- MuClient version 4.43 -->

<!-- Plugin "EmoteLegend" generated by Plugin Wizard -->

<muclient>
<plugin
   name="EmoteLegend"
   author="Josh/Armyboy"
   id="cd8fc0acb178fa8f541f0d93"
   language="Lua"
   purpose="Provides a Legend for the Emote Syntax in Armageddon"
   date_written="2010-02-21 20:39:30"
   requires="4.43"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Creates a small legend in the lower right hand corner with all the emote symbols that Armageddon MUD uses.  Starts Minimize.  Click the double arrow to expand.
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Script  -->


<script>
<![CDATA[
function MainWindow()
  win = GetPluginID ()
  EmoteKey = {
      [1]  =  "Sym  Reference  Target",
  	  [2]  =  " ~   (sdesc)     you",
	  [3]  =  " !    him        you",
	  [4]  =  " %   (sdesc)'s   your",
	  [5]  =  " ^    his        your",
	  [6]  =  " #    he         you",
	  [7]  =  " &    himself    yourself",
	  [8]  =  " =   (sdesc)'s   yours",
	  [9]  =  " +    his        yours",
	  }
  WindowCreate(win, 0, 0, 185, 145, 8, 0, 986895)
  WindowLine(win, 0, 0, 195, 0, 14737632, 2, 1)
  WindowLine(win, 0, 0, 0, 160, 14737632, 2, 1)
  WindowFont(win, "f", "Courier New", 9, false, false, false, false)
  WindowFont(win, "b", "Courier New", 12, true, false, false, false)
  WindowFont(win, "u", "Courier New", 9, true, false, true, false)
  top = 2
  height = WindowFontInfo (win, "f", 1)
  for i,v in ipairs(EmoteKey) do
    if i ==  1 then
	  WindowText(win, "u", v, 4, top, 0, 0, 16053492, false)
	else
      WindowText(win, "f", v, 4, top, 0, 0, 16053492, false)
	end
	top = top + height
  end
  MinW = WindowTextWidth(win, "b", "»", false)
  MinL = WindowInfo(win, 3) - MinW - 5
  MinT = WindowInfo(win, 4) - height - 5
  MinR = WindowInfo(win, 3)
  MinB = WindowInfo(win, 4)
  WindowText(win, "b", "»", MinL, MinT, MinR, MinB, 11053224, false)
  WindowAddHotspot(win, "Minimize", MinL, MinT, MinR, MinB,
                   "",   --mouseover
                   "",   --cancelmouseover
                   "",   --mousedown
                   "",   --cancelmousedown
                   "mouseup",   --mouseup
                   "Minimize this window",
			   	   1, 0)
WindowShow (win, True)
end --MainWindow


function mouseup(flags, hotspot_id)
  local action = {
    ["Minimize"] =    function () Minimize()           end,
    ["Show"] =        function () WindowDelete(win2)
                        WindowShow(win, true)           end,
  }
  action[hotspot_id]()
end --mouseup


function Minimize()                                --minimize the big window
  WindowShow(win, false)
  win2 = GetPluginID().."2"
  WindowCreate(win2, 0, 0, 1, 1, 8, 0, 986895)
  WindowFont(win2, "b", "Courier New", 12, true, false, false, false)
  Height = WindowFontInfo (win2, "b", 1)
  local WinH = Height + 2
  local WinW = WindowTextWidth(win2, "b", "« ", false)
  WindowCreate(win2, 0, 0, WinW, WinH, 8, 0, 986895)
  WindowLine(win2, 0, 0, 0, WinH, 14737632, 2, 1)
  WindowLine(win2, 0, 0, WinW, 0, 14737632, 2, 1)
  local MaxL = 0
  local MaxT = 0
  local MaxR = WinW
  local MaxB = WinH
  WindowText(win2, "b", "«",
             MaxL+4, MaxT, 0, 0,
             11053224, false)
  WindowAddHotspot(win2, "Show", MaxL, MaxT, MaxR, MaxB,
                   "",   --mouseover
                   "",   --cancelmouseover
                   "",   --mousedown
                   "",   --cancelmousedown
                   "mouseup",   --mouseup
                   "Expand to see the Emote Symbol Key",
                   1, 0)
  WindowShow(win2, true)
end --Minimize


MainWindow()
Minimize()
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="EmoteLegend:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>

There's a hotspot on the lower right which allows you to "minimize" the window by setting WindowShow to false, and creates a second miniwindow with a hotspot allowing you to maximize the miniwindow. When you click the hotspot to "show" the main window again, it's supposed to delete the second miniwindow, and sets WindowShow to true on the first one.

In 4.72, this plugin (and one that uses the same mechanism to show/hide) works as intended. When you upgrade to 4.73, it appears as if the second miniwindow never deletes as it's supposed to, and ends up being permanently displayed over the main window.

I hope my explanation of what's happening makes sense. If not, take the plugin for a test drive and it should be easy enough to see.

As this is a change to the plugin behavior in previous versions, and I don't see anything in the release notes that this change is intentional, I'm assuming this is a bug. Hope I've provided enough to track it down.
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #1 on Sat 28 May 2011 09:05 PM (UTC)

Amended on Sat 28 May 2011 09:14 PM (UTC) by Fiendish

Message
Template:post=11047 Please see the forum thread: http://gammon.com.au/forum/?id=11047.


Miniwindows deleting themselves wasn't safe, so Nick made it impossible to try. That is actually in the release notes for 4.73. A more compatible solution to that problem *might* be to mimic the change from the recent discussion on cancelmouseover ordering here:
http://mushclient.com/forum/bbshowpost.php?id=11139
But I haven't really thought about it much.
In the meantime, I think you can safely either use doafterspecial or use a method other than deletion.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 29 May 2011 12:02 AM (UTC)
Message
Yes he's right. Deleting yourself is unsafe and might lead to random crashes. Then I get complaints the client is flaky.

Either do the delete on a timer (could be 0.1 seconds) or just hide it instead.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by LezChap   (36 posts)  Bio
Date Reply #3 on Sun 29 May 2011 12:23 AM (UTC)
Message
Nick Gammon said:

Yes he's right. Deleting yourself is unsafe and might lead to random crashes. Then I get complaints the client is flaky.

Either do the delete on a timer (could be 0.1 seconds) or just hide it instead.


I did the latter...went through and fixed the plugins that used the unsafe code (even if I never had nor heard of a problem with it in my plugins). Yay for cleaner code?
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.


18,766 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.