render.PushFilterMag overflow crash

Like the title says, game crashes with popup “render.PushFilterMag overflow”.

Happens after console spams error “attempt to index field ‘Image’ (a nil value)”

My code:


local PANEL = {}
function PANEL:Paint( w, h )

	if ( self.Depressed && !self.Dragging ) then
		if ( self.Border != 8 ) then
			self.Border = 8
			self:OnDepressionChanged( true )
		end
	else
		if ( self.Border != 0 ) then
			self.Border = 0
			self:OnDepressionChanged( false )
		end
	end

	render.PushFilterMag( TEXFILTER.ANISOTROPIC )
	render.PushFilterMin( TEXFILTER.ANISOTROPIC )

	self.Image:PaintAt( 3 + self.Border, 3 + self.Border, 128 - 8 - self.Border * 2, 128 - 8 - self.Border * 2 )

	render.PopFilterMin()
	render.PopFilterMag()

	surface.SetDrawColor( 255, 255, 255, 255 )

	if ( !dragndrop.IsDragging() && ( self:IsHovered() || self.Depressed || self:IsChildHovered() ) ) then

		surface.SetMaterial( matOverlay_Hovered )
		self.Label:Hide()

	else

		surface.SetMaterial( matOverlay_Normal )
		self.Label:Show()

	end

	surface.DrawTexturedRect( self.Border, self.Border, w-self.Border*2, h-self.Border*2 )

	if ( self.AdminOnly ) then
		surface.SetMaterial( matOverlay_AdminOnly )
		surface.DrawTexturedRect( self.Border + 8, self.Border + 8, 16, 16 )
	end

end
vgui.Register("BrokenIcon", PANEL, "ContentIcon")

local BackPanel
function TeamMenu()
	if IsValid(BackPanel) then
		BackPanel:Remove()
	else
		BackPanel = vgui.Create("DFrame")
		BackPanel:MakePopup()
		BackPanel:SetTitle("Mode Picker")
		BackPanel:ShowCloseButton( false )
		BackPanel.btnClose:SetVisible( true )
		BackPanel.IconSandbox = vgui.Create("BrokenIcon", BackPanel)
		local BackPanelW, BackPanelH = BackPanel:GetSize()
		local TitleX, TitleY = BackPanel.lblTitle:GetPos()
		BackPanel.IconSandbox:SetPos(TitleX, TitleY + BackPanel.lblTitle:GetTall() + 2)
		BackPanel.IconSandbox:SetSize(64, 64)
		BackPanel.IconSandbox:SetMaterial("materials/SBIcon.png")
		BackPanel.IconSandbox:SetName("Sandbox Mode")
		BackPanel:InvalidateLayout( true )
		BackPanel:SizeToChildren(true, true)
		local PlayIconX, _ = BackPanel.IconSandbox:GetPos()
		BackPanel:SetWide(PlayIconX + BackPanel.IconSandbox:GetWide() + 1)
		BackPanel:Center()
	end
end

hook.Add("PlayerBindPress", "KeyMachineBroke", function(pl, bind, pressed)
	if string.find( bind,"gm_showteam" ) then
		TeamMenu()
	end
end)


The code worked fine when I was using a ContentIcon instead of a custom panel for the panel break, but I wanted to change the Paint function, and I figured I would probably use the same icon multiple times, so I just went to sandbox/gamemode/spawnmenu/creationmenu/content/contenticon.lua and copied the Paint so I could change it. The line erroring out is


self.Image:PaintAt( 3 + self.Border, 3 + self.Border, 128 - 8 - self.Border * 2, 128 - 8 - self.Border * 2 )

from the Paint function.

Anyone know why this is happening/how to fix if possible?

Like it says, self.Image is nil
No where in your code are you you setting it