MCPcopy Create free account
hub / github.com/cogentcore/core / saveCached

Method saveCached

core/windowgeometry.go:284–307  ·  view source on GitHub ↗

saveCached saves the cached prefs -- called after timer delay, under the Mu.Lock

()

Source from the content-addressed store, hash-verified

282// saveCached saves the cached prefs -- called after timer delay,
283// under the Mu.Lock
284func (ws *windowGeometrySaver) saveCached() {
285 ws.lockFile() // not going to change our behavior if we can't lock!
286 if ws.needToReload() {
287 ws.open()
288 }
289 for winName, scmap := range ws.cache {
290 for scName, wgr := range scmap {
291 sc := system.TheApp.ScreenByName(scName)
292 if sc == nil {
293 continue
294 }
295 if ws.geometries[winName] == nil {
296 ws.geometries[winName] = make(map[string]windowGeometry)
297 }
298 ws.geometries[winName][sc.Name] = wgr
299 if DebugSettings.WinGeomTrace {
300 log.Printf("WindowGeometry: RecordPref: Saving for window: %v pos: %v size: %v screen: %v dpi: %v device pixel ratio: %v\n", winName, wgr.pos(), wgr.size(), sc.Name, sc.LogicalDPI, sc.DevicePixelRatio)
301 }
302 }
303 }
304 ws.resetCache()
305 ws.save()
306 ws.unlockFile()
307}
308
309// pref returns an existing preference for given window name, for given screen.
310// if the window name has a colon, only the part prior to the colon is used.

Callers 1

recordPrefMethod · 0.95

Calls 10

lockFileMethod · 0.95
needToReloadMethod · 0.95
openMethod · 0.95
resetCacheMethod · 0.95
saveMethod · 0.95
unlockFileMethod · 0.95
posMethod · 0.80
ScreenByNameMethod · 0.65
sizeMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected