diff classes/Button.lua @ 126:6a4b4d3c5fad

More fixes for button base class
author Flick <flickerstreak@gmail.com>
date Tue, 03 Mar 2009 23:18:35 +0000
parents 0c5017f6062d
children 729232aeeb5e
line wrap: on
line diff
--- a/classes/Button.lua	Tue Mar 03 23:18:05 2009 +0000
+++ b/classes/Button.lua	Tue Mar 03 23:18:35 2009 +0000
@@ -76,11 +76,12 @@
 end
 
 function Button:Destroy()
-  local f = self.frame
-  gridProxy:RemoveGridFrame(f)
-  f:Hide()
-  f:SetParent(trash)
-  f:ClearAllPoints()
+  local f = self:GetFrame()
+  if f then
+    f:Hide()
+    f:SetParent(trash)
+    f:ClearAllPoints()
+  end
 end
 
 function Button:GetFrame()
@@ -122,8 +123,8 @@
   local useCount = pool.useCount
   if id == nil then
     repeat
-      local nWraps = pool.nWraps
-      if useCount[hint] == nil or useCount[hint] == nWraps then
+      local nWraps = pool.nWraps or 0
+      if hint and (useCount[hint] == nil or useCount[hint] == nWraps) then
         id = hint
       else
         local start = hint or 1
@@ -148,7 +149,7 @@
         end
         pool.nWraps = nWraps + 1
       end
-    until id 
+    until id ~= nil
   end
   useCount[id] = (useCount[id] or 0) + 1
   return id