mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-13 12:27:40 +07:00
Dispose object Graphics2D if it isn't used (#5876)
This commit is contained in:
parent
1a8a86cb2c
commit
1d40b8a7de
@ -6,7 +6,7 @@ import java.awt.*
|
|||||||
import java.awt.image.BufferedImage
|
import java.awt.image.BufferedImage
|
||||||
|
|
||||||
|
|
||||||
class NativeFontDesktop(val size: Int) : NativeFontImplementation {
|
class NativeFontDesktop(private val size: Int) : NativeFontImplementation {
|
||||||
private val font by lazy {
|
private val font by lazy {
|
||||||
Font("", Font.PLAIN, size)
|
Font("", Font.PLAIN, size)
|
||||||
}
|
}
|
||||||
@ -14,7 +14,9 @@ class NativeFontDesktop(val size: Int) : NativeFontImplementation {
|
|||||||
val bi = BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR)
|
val bi = BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR)
|
||||||
val g = bi.createGraphics()
|
val g = bi.createGraphics()
|
||||||
g.font = font
|
g.font = font
|
||||||
g.fontMetrics!!
|
val fontMetrics = g.fontMetrics
|
||||||
|
g.dispose()
|
||||||
|
fontMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFontSize(): Int {
|
override fun getFontSize(): Int {
|
||||||
@ -42,6 +44,7 @@ class NativeFontDesktop(val size: Int) : NativeFontImplementation {
|
|||||||
pixmap.drawPixel(i, j)
|
pixmap.drawPixel(i, j)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g.dispose()
|
||||||
return pixmap
|
return pixmap
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user