Fixed Crash when calling the Text render function with super weird content, causing a nil value as rendered text
This commit is contained in:
1 parent
57c01b2cc6
commit
8eec9d4855
1 file changed
+7
-5
+7
-5
@@ -806,7 +806,7 @@ end
|
|||||||
|
|
||||||
-- Searches thru the given string and replaces Iconplaceholders with icons.
|
-- Searches thru the given string and replaces Iconplaceholders with icons.
|
||||||
-- Returns 2 values. the string without the placeholders but with an accurate space between lines. and a table of all Inline Sprites
|
-- Returns 2 values. the string without the placeholders but with an accurate space between lines. and a table of all Inline Sprites
|
||||||
function EID:filterIconMarkup(text, textPosX, textPosY)
|
function EID:filterIconMarkup(text)
|
||||||
local spriteTable = {}
|
local spriteTable = {}
|
||||||
for word in string.gmatch(text, "{{.-}}") do
|
for word in string.gmatch(text, "{{.-}}") do
|
||||||
local textposition = string.find(text, word)
|
local textposition = string.find(text, word)
|
||||||
@@ -1059,11 +1059,13 @@ function EID:renderString(str, position, scale, kcolor)
|
|||||||
for _, textPart in ipairs(textPartsTable) do
|
for _, textPart in ipairs(textPartsTable) do
|
||||||
local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1], position.X, position.Y)
|
local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1], position.X, position.Y)
|
||||||
EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y)
|
EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y)
|
||||||
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
|
if strFiltered then -- prevent possible crash when strFiltered is nil
|
||||||
if EID.CachingDescription then
|
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
|
||||||
table.insert(EID.CachedStrings[#EID.CachedStrings], {strFiltered, position.X + offsetX, position.Y, textPart[2], textPart[4], EID.Config["Transparency"]})
|
if EID.CachingDescription then
|
||||||
|
table.insert(EID.CachedStrings[#EID.CachedStrings], {strFiltered, position.X + offsetX, position.Y, textPart[2], textPart[4], EID.Config["Transparency"]})
|
||||||
|
end
|
||||||
|
offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X
|
||||||
end
|
end
|
||||||
offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X
|
|
||||||
end
|
end
|
||||||
return textPartsTable[#textPartsTable][2]
|
return textPartsTable[#textPartsTable][2]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user