Skip to content

Commit 90a9bb9

Browse files
committed
fix: SetVertexColor protection
1 parent 35a69cb commit 90a9bb9

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

Skin/backdrop.lua

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ local function RecycleColor(color)
7575
colorPool[colorPoolSize] = color
7676
end
7777
end
78+
79+
-- WoW 12.0 changed Texture:SetVertexColor to prefer a color object.
80+
-- Aurora's custom Color objects are not always accepted by the C API,
81+
-- so convert to Blizzard's CreateColor() object when available.
82+
local vertexColorCompat = _G.CreateColor and _G.CreateColor(1, 1, 1, 1)
83+
local function SetRegionVertexColor(region, color)
84+
if not region or not color then
85+
return
86+
end
87+
88+
local r, g, b, a = color:GetRGBA()
89+
90+
if vertexColorCompat then
91+
vertexColorCompat:SetRGBA(r, g, b, a)
92+
local ok = _G.pcall(region.SetVertexColor, region, vertexColorCompat)
93+
if ok then
94+
return
95+
end
96+
end
97+
98+
_G.pcall(region.SetVertexColor, region, r, g, b, a)
99+
end
78100
-- Table pool for CopyBackdrop — avoids creating 3 tables (copy + insets + offsets)
79101
-- per Base.CreateBackdrop call. Frames that get re-skinned return their old
80102
-- backdropInfo to the pool via Base.CreateBackdrop.
@@ -388,7 +410,7 @@ local BackdropMixin do
388410

389411
local center = Util.GetNineSlicePiece(self, "Center")
390412
if center then
391-
center:SetVertexColor(self.backdropInfo.backdropColor:GetRGBA())
413+
SetRegionVertexColor(center, self.backdropInfo.backdropColor)
392414
end
393415
--return _G.BackdropTemplateMixin.SetBackdropColor(self, self.backdropInfo.backdropColor:GetRGBA())
394416
end
@@ -405,7 +427,7 @@ local BackdropMixin do
405427
if pieceName ~= "Center" then
406428
local region = Util.GetNineSlicePiece(self, pieceName)
407429
if region then
408-
region:SetVertexColor(backdropBorderColor:GetRGBA());
430+
SetRegionVertexColor(region, backdropBorderColor)
409431
end
410432
end
411433
end

0 commit comments

Comments
 (0)