Skip to content

Commit

Permalink
fix some
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Nov 16, 2020
1 parent 723b24b commit 08cdbee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type MsgPackResolver() =
s_resolver.GetFormatter<'a>()

let startMainWindow app serveropts =
let app = app()
Model.Start serveropts

let cfg = config.load()
Expand All @@ -81,6 +82,7 @@ let startMainWindow app serveropts =
0

let startCrashReportWindow app ex =
let app = app()
FVim.log.trace "main" "displaying crash dialog"
FVim.log.trace "main" "exception: %O" ex
let code, msgs = States.get_crash_info()
Expand Down Expand Up @@ -115,18 +117,19 @@ let main(args: string[]) =
)
System.Console.OutputEncoding <- System.Text.Encoding.Unicode

// Avalonia initialization
let builder = lazy buildAvaloniaApp()
let lifetime = lazy new ClassicDesktopStyleApplicationLifetime()
let app =
let app () =
// Avalonia initialization
let lifetime = lifetime.Value
if not builder.IsValueCreated then
let _ = builder.Value.SetupWithLifetime(lifetime)
()
// Avalonia is initialized. SynchronizationContext-reliant code should be working by now;
(fun (win: Avalonia.Controls.Window) ->
let lifetime = lifetime.Value
let builder = builder.Value
let _ = builder.SetupWithLifetime(lifetime)
lifetime.ShutdownMode <- Controls.ShutdownMode.OnMainWindowClose
lifetime.MainWindow <- win
lifetime.Start(args) |> ignore)
// Avalonia is initialized. SynchronizationContext-reliant code should be working by now;

try
let opts = parseOptions args
Expand Down
6 changes: 3 additions & 3 deletions states.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Event =
| Exit

let private _stateChangeEvent = Event<string>()
let private _appLifetime = Avalonia.Application.Current.ApplicationLifetime :?> Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime
let private _appLifetime = lazy(Avalonia.Application.Current.ApplicationLifetime :?> Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime)
let mutable private _crashcode = 0
let private _errormsgs = ResizeArray<string>()

Expand Down Expand Up @@ -245,7 +245,7 @@ let backgroundCompositionToString =
| Acrylic -> "acrylic"
| Transparent -> "transparent"

let Shutdown code = _appLifetime.Shutdown code
let Shutdown code = _appLifetime.Value.Shutdown code

let get_crash_info() =
_crashcode, _errormsgs
Expand Down Expand Up @@ -273,7 +273,7 @@ let msg_dispatch =
_errormsgs.Add err
| Exit ->
trace "rpc" "shutting down application lifetime"
_appLifetime.Shutdown()
_appLifetime.Value.Shutdown()
| Crash code ->
trace "rpc" "neovim crashed with code %d" code
_crashcode <- code
Expand Down

0 comments on commit 08cdbee

Please sign in to comment.