fix(interop): resolve native resource leaks in GTK and WebKit interop
All checks were successful
CI / Build (Linux) (push) Successful in 21s

Fix critical memory leaks identified in architecture review: Add signal handler disconnection in WebKitNative (load-changed and script-dialog signals now properly cleaned up), implement GTK idle callback cleanup with automatic removal on completion, add dlclose() calls for WebKit library handles, track GTK signal IDs in GtkSkiaSurfaceWidget for proper disposal. Replace empty catch blocks in GestureManager with logged exception handling. Add WebKitNative.Cleanup() and GtkNative.ClearCallbacks() methods for application shutdown.
This commit is contained in:
2026-03-06 23:14:53 -05:00
parent c5221ba580
commit 3412cb982e
22 changed files with 1208 additions and 50 deletions

View File

@@ -51,6 +51,13 @@ public static class GtkThemeService
return;
}
// Unreference previous CSS provider to prevent leak
if (_currentCssProvider != IntPtr.Zero)
{
GtkNative.g_object_unref(_currentCssProvider);
_currentCssProvider = IntPtr.Zero;
}
// Create new CSS provider
IntPtr newProvider = GtkNative.gtk_css_provider_new();
if (newProvider == IntPtr.Zero)
@@ -63,6 +70,7 @@ public static class GtkThemeService
if (!GtkNative.gtk_css_provider_load_from_data(newProvider, css, -1, IntPtr.Zero))
{
DiagnosticLog.Error("GtkThemeService", "Failed to load CSS data");
GtkNative.g_object_unref(newProvider);
return;
}