mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
ui: Bug fix: ScreenScale should not cause deadlock (#264)
This commit is contained in:
parent
750c2e08df
commit
d08beef412
@ -28,6 +28,7 @@ func CurrentFPS() float64 {
|
||||
}
|
||||
|
||||
func IsRunning() bool {
|
||||
// TODO: Need lock?
|
||||
if currentRunContext == nil {
|
||||
return false
|
||||
}
|
||||
|
6
run.go
6
run.go
@ -15,6 +15,7 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/loop"
|
||||
@ -143,7 +144,12 @@ func SetScreenScale(scale float64) {
|
||||
|
||||
// ScreenScale returns the current screen scale.
|
||||
//
|
||||
// If Run is not called, this returns NaN.
|
||||
//
|
||||
// This function is concurrent-safe.
|
||||
func ScreenScale() float64 {
|
||||
if !loop.IsRunning() {
|
||||
return math.NaN()
|
||||
}
|
||||
return ui.ScreenScale()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user