Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
if: matrix.config.os == 'ubuntu-latest'
run: dotnet format Source/gtk-sharp.sln --verify-no-changes --no-restore
- name: Install Deps
run: pip3 install meson ninja
run: pip3 install meson ninja --break-system-packages
- name: Install Windows Deps
if: matrix.config.os == 'windows-latest'
run: choco install winflexbison3 pkgconfiglite -y --allow-empty-checksum
Expand Down
6 changes: 4 additions & 2 deletions Source/glib/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Copyright (c) 2013 Andres G. Aragoneses
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
Expand Down Expand Up @@ -66,7 +66,7 @@ protected virtual void Dispose(bool disposing) {
if (tref == null)
return;

if (disposing)
if (disposing || !FinalizeOnMainThread)
tref.Dispose();
else
tref.QueueUnref();
Expand All @@ -76,6 +76,8 @@ protected virtual void Dispose(bool disposing) {

public static bool WarnOnFinalize { get; set; }

public static bool FinalizeOnMainThread { get; set; } = true;

[DllImport(Global.GObjectNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_object_ref(IntPtr raw);

Expand Down
8 changes: 6 additions & 2 deletions Source/glib/Opaque.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ protected virtual void DisposeManagedResources() {
protected virtual void DisposeUnmanagedResources() {
if (!Owned || DisposeUnmanagedFunc == null)
return;
FinalizerInfo info = new FinalizerInfo(DisposeUnmanagedFunc, Handle);
Timeout.Add(50, new TimeoutHandler(info.Handler));
if (Object.FinalizeOnMainThread) {
FinalizerInfo info = new FinalizerInfo(DisposeUnmanagedFunc, Handle);
Timeout.Add(50, new TimeoutHandler(info.Handler));
} else {
DisposeUnmanagedFunc(Handle);
}
}

protected internal bool Disposed { get; private set; } = false;
Expand Down