Skip to content

Commit

Permalink
fix(gtk): Add more descriptive message on initialization failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 19, 2023
1 parent 38b87e6 commit 58f5bf6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Uno.UI.Runtime.Skia.Gtk/GtkHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public void Run()
{
Windows.UI.Xaml.Documents.Inline.ApplyHarfbuzzWorkaround();

Gtk.Application.Init();
if (!InitializeGtk())
{
return;
}

SetupTheme();

ApiExtensibility.Register(typeof(Uno.ApplicationModel.Core.ICoreApplicationExtension), o => new CoreApplicationExtension(o));
Expand Down Expand Up @@ -137,6 +141,23 @@ public void Run()
Gtk.Application.Run();
}

private bool InitializeGtk()
{
try
{
Gtk.Application.Init();
return true;
}
catch(System.TypeInitializationException e)
{
if (this.Log().IsEnabled(LogLevel.Error))
{
this.Log().Error($"Unable to initialize Gtk, visit https://aka.platform.uno/gtk-install for more information.", e);
}
return false;
}
}

void DispatchNative(System.Action d)
{
if (Gtk.Application.EventsPending())
Expand Down

0 comments on commit 58f5bf6

Please sign in to comment.