Skip to content

Commit 58f5bf6

Browse files
committed
fix(gtk): Add more descriptive message on initialization failure
1 parent 38b87e6 commit 58f5bf6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/Uno.UI.Runtime.Skia.Gtk/GtkHost.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ public void Run()
8787
{
8888
Windows.UI.Xaml.Documents.Inline.ApplyHarfbuzzWorkaround();
8989

90-
Gtk.Application.Init();
90+
if (!InitializeGtk())
91+
{
92+
return;
93+
}
94+
9195
SetupTheme();
9296

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

144+
private bool InitializeGtk()
145+
{
146+
try
147+
{
148+
Gtk.Application.Init();
149+
return true;
150+
}
151+
catch(System.TypeInitializationException e)
152+
{
153+
if (this.Log().IsEnabled(LogLevel.Error))
154+
{
155+
this.Log().Error($"Unable to initialize Gtk, visit https://aka.platform.uno/gtk-install for more information.", e);
156+
}
157+
return false;
158+
}
159+
}
160+
140161
void DispatchNative(System.Action d)
141162
{
142163
if (Gtk.Application.EventsPending())

0 commit comments

Comments
 (0)