mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
ui: Bug fix: ScreenScale should not cause deadlock (#264)
This commit is contained in:
parent
1be6b546b7
commit
d6cf199956
@ -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