diff --git a/application.go b/application.go index 7a48c1c..6404556 100644 --- a/application.go +++ b/application.go @@ -147,7 +147,11 @@ func RunApplication (application Application) { // open config globalConfig, err := ApplicationConfig(GlobalApplicationDescription()) if err != nil { log.Fatalln("nasin: could not open config:", err) } - defer globalConfig.Close() + currentGlobalConfig = globalConfig + defer func () { + globalConfig.Close() + currentGlobalConfig = nil + } () styleConfigKey := "Style" iconSetConfigKey := "IconSet" @@ -224,6 +228,13 @@ func ApplicationConfig (app ApplicationDescription) (config.ConfigCloser, error) return config.NewConfig(user, system...) } +var currentGlobalConfig config.Config +// GlobalConfig returns the global config. This is managed by Nasin and must not +// be closed by the application. +func GlobalConfig () config.Config { + return currentGlobalConfig +} + func errorPopupf (title, format string, v ...any) func (func ()) { return func (callback func ()) { dialog, err := objects.NewDialogOk (