imawizard / MiguruWM

A tiling window manager for Windows
BSD 2-Clause "Simplified" License
39 stars 3 forks source link

Issue with last commits #21

Closed kyx0r closed 1 year ago

kyx0r commented 1 year ago

The popup fix commit exposed a bug: https://github.com/imawizard/MiguruWM/commit/a1454e9a14ed6a1f4ce3b190c3e522f0ea3860ac

Error: This variable has not been assigned a value.

Specifically: local iconWidth

    ---- C:\msys64\home\User\progs\MiguruWM\lib\Popup.ahk
    089: iconHeight := 0
    090: }
▶   093: msgX := Max(horzPadding // 2 + iconWidth / 1.5, horzPadding // 4 + iconWidth)
    094: msg.GetPos(, , &msgWidth, &msgHeight)
    095: guiWidth := msgWidth + horzPadding + iconWidth // 2

The current thread will exit.

Call stack:
C:\msys64\home\User\progs\MiguruWM\lib\Popup.ahk (93) : [Popup.Prototype.__New] msgX := Max(horzPadding // 2 + iconWidth / 1.5, horzPadding // 4 + iconWidth)
C:\msys64\home\User\progs\MiguruWM\mwm.ahk (50) : [Object.Call] Return  Popup(text, ObjMerge({ showIcon: true, }, opts))
C:\msys64\home\User\progs\MiguruWM\mwm.ahk (50) : [] Return  Popup(text, ObjMerge({ showIcon: true, }, opts))
C:\msys64\home\User\progs\MiguruWM\lib\miguru\miguru.ahk (702) : [Func.Prototype.Call] this._opts.showPopup.Call(ws.Layout.DisplayName, { activeMonitor: this.activeMonitor.Index, })
C:\msys64\home\User\progs\MiguruWM\lib\miguru\miguru.ahk (702) : [MiguruWM.Prototype._onRequest] this._opts.showPopup.Call(ws.Layout.DisplayName, { activeMonitor: this.activeMonitor.Index, })
C:\msys64\home\User\progs\MiguruWM\lib\miguru\events.ahk (151) : [WMEvents.Prototype._onMessage] ret := this._onRequest(req)
C:\msys64\home\User\progs\MiguruWM\lib\miguru\events.ahk (84) : [Func.Prototype.Call] Return  fn.Call(ObjFromPtrAddRef(self), args*)
C:\msys64\home\User\progs\MiguruWM\lib\miguru\events.ahk (84) : [] Return  fn.Call(ObjFromPtrAddRef(self), args*)

this is just changing layout.

Here's a quick patch to fix it

diff --git a/lib/Popup.ahk b/lib/Popup.ahk
index 5e93637..39c398f 100644
--- a/lib/Popup.ahk
+++ b/lib/Popup.ahk
@@ -70,6 +70,9 @@ class Popup {

             ;; Create window hidden to get text width and height.
             g.Show("Hide")
+            icon := ""
+            iconWidth := 0
+            iconHeight := 0

             if showIcon {
                 file := A_IconFile
@@ -83,10 +86,6 @@ class Popup {
                     icon := g.Add("Picture", "Icon1", file)
                     icon.GetPos(, , &iconWidth, &iconHeight)
                 }
-            } else {
-                icon := ""
-                iconWidth := 0
-                iconHeight := 0
             }

             ;; Resize window to message plus padding.
imawizard commented 1 year ago

Thanks 😊