mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
fix memory leak by adding Free on font surface
This commit is contained in:
parent
8377acd017
commit
d26152e14f
@ -471,7 +471,7 @@ func (self *BleListMessageBox) Draw() {
|
|||||||
|
|
||||||
rect2_ := rect.Rect(x,y,w,h)
|
rect2_ := rect.Rect(x,y,w,h)
|
||||||
surface.Blit(self.CanvasHWND,my_text,&rect2_,nil)
|
surface.Blit(self.CanvasHWND,my_text,&rect2_,nil)
|
||||||
|
my_text.Free()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -383,7 +383,7 @@ func (self *WifiListMessageBox) Draw() {
|
|||||||
|
|
||||||
rect_2 := rect.Rect(x,y,w,h)
|
rect_2 := rect.Rect(x,y,w,h)
|
||||||
surface.Blit(self.CanvasHWND,my_text,&rect_2,nil)
|
surface.Blit(self.CanvasHWND,my_text,&rect_2,nil)
|
||||||
|
my_text.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------WifiList---------------------------------
|
//---------WifiList---------------------------------
|
||||||
|
|||||||
@ -132,6 +132,11 @@ func (self *FootBar) ReadFootBarIcons( icondir string) {
|
|||||||
it.AddLabel("game", self.LabelFont)
|
it.AddLabel("game", self.LabelFont)
|
||||||
it.Adjust( self.IconWidth/2+i*self.IconWidth, self.IconHeight/2+2, self.IconWidth,self.IconHeight,0)
|
it.Adjust( self.IconWidth/2+i*self.IconWidth, self.IconHeight/2+2, self.IconWidth,self.IconHeight,0)
|
||||||
it.IconIndex = i
|
it.IconIndex = i
|
||||||
|
if val, ok := self.Icons[v]; ok {
|
||||||
|
if val.(*FootBarIconItem).ImgSurf != nil {
|
||||||
|
val.(*FootBarIconItem).ImgSurf.Free()
|
||||||
|
}
|
||||||
|
}
|
||||||
self.Icons[v] = it
|
self.Icons[v] = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,8 +182,10 @@ func (self *FootBar) UpdateNavText(texts string) {
|
|||||||
my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"),nil)
|
my_text := font.Render(self.LabelFont, text_, true, self.SkinManager.GiveColor("Text"),nil)
|
||||||
final_piece = text_
|
final_piece = text_
|
||||||
if int(my_text.W) >= left_width {
|
if int(my_text.W) >= left_width {
|
||||||
|
my_text.Free()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
my_text.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("finalpiece %s\n", final_piece)
|
fmt.Printf("finalpiece %s\n", final_piece)
|
||||||
|
|||||||
@ -104,6 +104,7 @@ func (self *Label) DrawCenter(bold bool) { // default bold is false
|
|||||||
rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
|
rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
|
||||||
|
|
||||||
surface.Blit(self.CanvasHWND,my_text,rect_,nil)
|
surface.Blit(self.CanvasHWND,my_text,rect_,nil)
|
||||||
|
my_text.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Label) Draw() {
|
func (self *Label) Draw() {
|
||||||
@ -114,5 +115,5 @@ func (self *Label) Draw() {
|
|||||||
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
rect_ := rect.Rect(self.PosX,self.PosY,self.Width,self.Height)
|
||||||
|
|
||||||
surface.Blit(self.CanvasHWND,my_text,&rect_,nil)
|
surface.Blit(self.CanvasHWND,my_text,&rect_,nil)
|
||||||
|
my_text.Free()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,7 @@ func (self *MessageBox) Draw() {
|
|||||||
|
|
||||||
dest_rect := rect.Rect(x,y, word_width,word_height)
|
dest_rect := rect.Rect(x,y, word_width,word_height)
|
||||||
surface.Blit(self.CanvasHWND, word_surface, &dest_rect,nil)
|
surface.Blit(self.CanvasHWND, word_surface, &dest_rect,nil)
|
||||||
|
word_surface.Free()
|
||||||
if len(words) == 1 {
|
if len(words) == 1 {
|
||||||
x+=word_width
|
x+=word_width
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -126,6 +126,7 @@ func (self *MultiLabel) blit_text(surf *sdl.Surface,text string, pos_x,pos_y int
|
|||||||
}
|
}
|
||||||
rect_ := rect.Rect(x,y,self.Width,self.Height)
|
rect_ := rect.Rect(x,y,self.Width,self.Height)
|
||||||
surface.Blit(surf,word_surface,&rect_,nil)
|
surface.Blit(surf,word_surface,&rect_,nil)
|
||||||
|
word_surface.Free()
|
||||||
x += (word_width+space)
|
x += (word_width+space)
|
||||||
}
|
}
|
||||||
x = pos_x
|
x = pos_x
|
||||||
|
|||||||
@ -70,5 +70,5 @@ func (self *TextItem) Draw() {
|
|||||||
|
|
||||||
rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
|
rect_ := draw.MidRect(self.PosX,self.PosY,self.Width,self.Height,Width,Height)
|
||||||
surface.Blit(self.Parent.GetCanvasHWND(),my_text,rect_,nil)
|
surface.Blit(self.Parent.GetCanvasHWND(),my_text,rect_,nil)
|
||||||
|
my_text.Free()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,6 +126,7 @@ func (self *Textarea) BuildBlitText() {
|
|||||||
linenumber += 1
|
linenumber += 1
|
||||||
blit_rows = append(blit_rows,[]string{})
|
blit_rows = append(blit_rows,[]string{})
|
||||||
}
|
}
|
||||||
|
t.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(blit_rows) == 1 {
|
if len(blit_rows) == 1 {
|
||||||
@ -182,7 +183,7 @@ func (self *Textarea) BlitText() {
|
|||||||
rect_ := rect.Rect(x,y,0,0)
|
rect_ := rect.Rect(x,y,0,0)
|
||||||
surface.Blit(self.CanvasHWND,t,&rect_,nil)
|
surface.Blit(self.CanvasHWND,t,&rect_,nil)
|
||||||
x += surface.GetWidth(t)
|
x += surface.GetWidth(t)
|
||||||
|
t.Free()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,11 +211,13 @@ func (self *Textarea) Cursor() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
x += surface.GetWidth(t)
|
x += surface.GetWidth(t)
|
||||||
|
t.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
c_t := font.Render(self.FontObj,"_",true,&color.Color{0,0,0,255},nil)
|
c_t := font.Render(self.FontObj,"_",true,&color.Color{0,0,0,255},nil)
|
||||||
rect_ := rect.Rect(x+1,y-2,0,0)
|
rect_ := rect.Rect(x+1,y-2,0,0)
|
||||||
surface.Blit(self.CanvasHWND,c_t,&rect_,nil)
|
surface.Blit(self.CanvasHWND,c_t,&rect_,nil)
|
||||||
|
c_t.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Textarea) Draw() {
|
func (self *Textarea) Draw() {
|
||||||
|
|||||||
@ -469,11 +469,13 @@ func (self *TitleBar) Draw(title string) {
|
|||||||
title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"),nil)
|
title_text_surf := font.Render(self.TitleFont, self.Title, true, self.SkinManager.GiveColor("Text"),nil)
|
||||||
|
|
||||||
surface.Blit(self.CanvasHWND,title_text_surf, draw.MidRect(title_text_w/2+self.LOffset,title_text_h/2+(self.BarHeight-title_text_h)/2,title_text_w,title_text_h,Width,Height),nil)
|
surface.Blit(self.CanvasHWND,title_text_surf, draw.MidRect(title_text_w/2+self.LOffset,title_text_h/2+(self.BarHeight-title_text_h)/2,title_text_w,title_text_h,Width,Height),nil)
|
||||||
|
title_text_surf.Free()
|
||||||
|
|
||||||
time_text_surf := font.Render(self.TimeFont, cur_time,true,self.SkinManager.GiveColor("Text"),nil)
|
time_text_surf := font.Render(self.TimeFont, cur_time,true,self.SkinManager.GiveColor("Text"),nil)
|
||||||
surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
|
surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
|
||||||
|
|
||||||
|
time_text_surf.Free()
|
||||||
|
|
||||||
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
|
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
|
||||||
|
|
||||||
self.Icons["bluetooth"].NewCoord(start_x - self.IconWidth,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
|
self.Icons["bluetooth"].NewCoord(start_x - self.IconWidth,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user