mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 06:25:33 +00:00
4a6b18ee0f
* generator/Parser.cs: use XmlDocument.Load (Stream). The one using (String) expects an uri. * generator/Signal.cs: always remove the delegate from the signal callback (prior to this, the last handler was not being removed). Dispose the callback (ie, disconnect from the signal) when there are no registered delegates to handle it. * generator/SignalHandler.cs: added 2 new fields to hold the instance and the handler ID. The finalization is now done in Dispose and disconnects the signal handler when no delegate will handle the signal. Changed gobject-2.0 to libgobject-2.0-0.dll. * glib/SignalCallback.cs: implemented IDisposable interface. svn path=/trunk/gtk-sharp/; revision=11976
84 lines
1.6 KiB
C#
84 lines
1.6 KiB
C#
// GtkSharp.SignalCallback.cs - Signal callback base class implementation
|
|
//
|
|
// Authors: Mike Kestner <mkestner@speakeasy.net>
|
|
//
|
|
// (c) 2001 Mike Kestner
|
|
|
|
namespace GtkSharp {
|
|
using System;
|
|
using System.Collections;
|
|
using System.Runtime.InteropServices;
|
|
using GLib;
|
|
|
|
/// <summary>
|
|
/// SignalCallback Class
|
|
/// </summary>
|
|
///
|
|
/// <remarks>
|
|
/// Base Class for GSignal to C# event marshalling.
|
|
/// </remarks>
|
|
|
|
public abstract class SignalCallback : IDisposable {
|
|
|
|
// A counter used to produce unique keys for instances.
|
|
protected static int _NextKey = 0;
|
|
|
|
// Hashtable containing refs to all current instances.
|
|
protected static Hashtable _Instances = new Hashtable ();
|
|
|
|
// protected instance members
|
|
protected GLib.Object _obj;
|
|
protected Delegate _handler;
|
|
protected int _key;
|
|
protected System.Type _argstype;
|
|
|
|
/// <summary>
|
|
/// SignalCallback Constructor
|
|
/// </summary>
|
|
///
|
|
/// <remarks>
|
|
/// Initializes instance data.
|
|
/// </remarks>
|
|
|
|
public SignalCallback (GLib.Object obj, Delegate eh, System.Type argstype)
|
|
{
|
|
_key = _NextKey++;
|
|
_obj = obj;
|
|
_handler = eh;
|
|
_argstype = argstype;
|
|
_Instances [_key] = this;
|
|
}
|
|
|
|
public void AddDelegate (Delegate d)
|
|
{
|
|
_handler = Delegate.Combine (_handler, d);
|
|
}
|
|
|
|
public void RemoveDelegate (Delegate d)
|
|
{
|
|
_handler = Delegate.Remove (_handler, d);
|
|
}
|
|
|
|
public void Dispose ()
|
|
{
|
|
Dispose (true);
|
|
GC.SuppressFinalize (this);
|
|
}
|
|
|
|
protected virtual void Dispose (bool disposing)
|
|
{
|
|
if (disposing) {
|
|
_obj = null;
|
|
_handler = null;
|
|
_argstype = null;
|
|
}
|
|
}
|
|
|
|
~SignalCallback ()
|
|
{
|
|
Dispose (false);
|
|
}
|
|
}
|
|
}
|
|
|