AceGUI-3.0 "Label" UpdateImageAnchor halting execution of code (on some occasions) #621


  • Defect
Open
  • Xruptor created this issue Dec 7, 2022

    There is some sort of issue going on in UpdateImageAnchor within the "Label" widget where occasionally execution of code halts when image:GetHeight() is called.  Preventing the rest of the positioning and code to execute properly.  I used print() and debug() lines and you can clearly see when the code just randomly halts on a few occasions.

     

    To reproduce this issue, you will need BagSync installed.

     

    Create a gnome character then kill a wolf.  Get a ruined pelt.

     

    Open BagSync search and do a search for "ruin" you should get one result.

    Now type in "test" and search for that to clear it.

    Search for "ruin" once again and you will notice the bar is returned but the labeling is not position correctly.

     

    If you analyze the executions during this process.  UpdateImageAnchor stops execution around the time it hits image:GetHeight().  To further test this.  I replaced all instances of image:GetHeight() the number 18 in the function.  (basically I hardcoded a size).  I repeated the steps above and it worked perfectly.  Which is telling me that somehow in some way the code execution of this particular function just randomly stops execution when image:GetHeight() is called.  It took me quite a awhile to figure this out as I had to use several debug lines in several locations numbered to see what was going on.  At first I thought it was 

    GetStringHeight() but it's definitely GetHeight() for image variable.
     
    You may want to look into that.  One simply way of doing it is just to set image.height and image.width variables when SetImageSize is called.  Then simply just refer to image.height instead of  image:GetHeight().  Unless you can figure out what exactly is going on that is preventing the code from executing the rest of the function.
     
  • Xruptor added a tag Defect Dec 7, 2022
  • Xruptor posted a comment Dec 7, 2022
    	["SetImageSize"] = function(self, width, height)
    		self.image:SetWidth(width)
    		self.image:SetHeight(height)
            self.image.width = width
            self.image.height = height
    		self.image:SetHeight(height)
    		UpdateImageAnchor(self)
    	end,

     

    and an updated 

     

    	if self.imageshown then
            local imageHeight = image.height or 16
            local imageWidth = image.width or 16
    
    		if (width - imageWidth) < 200 or (label:GetText() or "") == "" then
    			-- image goes on top centered when less than 200 width for the text, or if there is no text
    			image:SetPoint("TOP")
    			label:SetPoint("TOP", image, "BOTTOM")
    			label:SetPoint("LEFT")
    			label:SetWidth(width)
    			height = imageHeight + label:GetStringHeight()
    		else
    			-- image on the left
    			image:SetPoint("TOPLEFT")
    			if imageHeight > label:GetStringHeight() then
    				label:SetPoint("LEFT", image, "RIGHT", 4, 0)
    			else
    				label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
    			end
    			label:SetWidth(width - imageWidth - 4)
    			height = max(imageHeight, label:GetStringHeight())
    		end
    	else
    		-- no image shown
    		label:SetPoint("TOPLEFT")
    		label:SetWidth(width)
    		height = label:GetStringHeight()
    	end

     

     

    Seem to fix the issue.  Again, I cannot pinpoint why that method is preventing the rest of the code to execute.


    Edited Dec 7, 2022

To post a comment, please login or register a new account.