Thread Tools Display Modes
06-18-17, 06:55 PM   #1
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
OnHyperLinkClick crashes the game.. sometimes

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:
  1. function HTMLHandler:page(message)
  2.     for i, button in pairs(self.Index.Buttons) do
  3.         if button.pageID == message then
  4.             return button:OnClick()
  5.         end
  6.     end
  7. end
  8.  
  9. function HTMLHandler:OnHyperlinkClick(linkData)
  10.     local startPoint, endPoint = linkData:find('%a+:')
  11.     local linkType = linkData:sub(startPoint, endPoint - 1)
  12.     local address = linkData:sub(endPoint + 1)
  13.  
  14.     if self[linkType] then
  15.         self[linkType](self, address, linkType)
  16.     end
  17. end
  18.  
  19. function IndexButton:OnClick()
  20.     -- the function doesn't actually look like this.
  21.     -- removed everything that has nothing to do with the problem.
  22.     -- the following line crashes the game when the faulty link is clicked.
  23.     self.HTML:SetText(self.content)
  24. end
__________________

Last edited by MunkDev : 06-18-17 at 07:08 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » OnHyperLinkClick crashes the game.. sometimes


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off