I'm using a SimpleHTML widget to display a bunch of fancy text written in HTML and on some of the pages, there are links to other pages.
E.g. <
a href=
"page:Page name">display text here</
a>
My code supports a bunch of different instructions for links and calls different handlers depending on what type of link it is. The page changing function causes
the same SimpleHTML object that contains the link to render a new page. This is when the game attempts to read from unallocated memory... sometimes.
All of the page links in the HTML work, except one. From this you could make the assumption that something is wrong with that particular link, but adding more content with another link to the same page as the faulty link doesn't cause the same issue.
If two links to different pages
on the same page are swapped, but the content is otherwise unchanged, then the faulty one is the one with the same ID in order of appearance. If the second link on a page is broken, then regardless of what it links to, the second link will remain broken. All other links will work.
Thoughts on this? My theory is that this has something to do either with the SimpleHTML widget is bugged in terms of recycling FontString objects to display content, or it has to do with scope. Perhaps there's even a slim chance that
my code is causing this.
Anyway, here's some code:
Lua Code:
function HTMLHandler:page(message)
for i, button in pairs(self.Index.Buttons) do
if button.pageID == message then
return button:OnClick()
end
end
end
function HTMLHandler:OnHyperlinkClick(linkData)
local startPoint, endPoint = linkData:find('%a+:')
local linkType = linkData:sub(startPoint, endPoint - 1)
local address = linkData:sub(endPoint + 1)
if self[linkType] then
self[linkType](self, address, linkType)
end
end
function IndexButton:OnClick()
-- the function doesn't actually look like this.
-- removed everything that has nothing to do with the problem.
-- the following line crashes the game when the faulty link is clicked.
self.HTML:SetText(self.content)
end