mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 10:55:30 +00:00
glib: Have SourceProxy implement the Dispose pattern
Its 2 subclasses, IdleProxy and TimeoutProxy, were already implementing it, so we factor this implementation into the base class.
This commit is contained in:
parent
813f56e00a
commit
f5211acb74
24
glib/Idle.cs
24
glib/Idle.cs
|
@ -44,30 +44,6 @@ namespace GLib {
|
|||
proxy_handler = new IdleHandlerInternal (Handler);
|
||||
}
|
||||
|
||||
~IdleProxy ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
// Both branches remove our delegate from the
|
||||
// managed list of handlers, but only
|
||||
// Source.Remove will remove it from the
|
||||
// unmanaged list also.
|
||||
|
||||
if (disposing)
|
||||
Remove ();
|
||||
else
|
||||
Source.Remove (ID);
|
||||
}
|
||||
|
||||
public bool Handler ()
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -31,11 +31,35 @@ namespace GLib {
|
|||
//
|
||||
// Base class for IdleProxy and TimeoutProxy
|
||||
//
|
||||
internal class SourceProxy {
|
||||
internal class SourceProxy : IDisposable {
|
||||
internal Delegate real_handler;
|
||||
internal Delegate proxy_handler;
|
||||
internal uint ID;
|
||||
|
||||
~SourceProxy ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
// Both branches remove our delegate from the
|
||||
// managed list of handlers, but only
|
||||
// Source.Remove will remove it from the
|
||||
// unmanaged list also.
|
||||
|
||||
if (disposing)
|
||||
Remove ();
|
||||
else
|
||||
Source.Remove (ID);
|
||||
}
|
||||
|
||||
internal void Remove ()
|
||||
{
|
||||
Source.RemoveSourceHandler (ID);
|
||||
|
|
|
@ -42,30 +42,6 @@ namespace GLib {
|
|||
proxy_handler = new TimeoutHandlerInternal (Handler);
|
||||
}
|
||||
|
||||
~TimeoutProxy ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
// Both branches remove our delegate from the
|
||||
// managed list of handlers, but only
|
||||
// Source.Remove will remove it from the
|
||||
// unmanaged list also.
|
||||
|
||||
if (disposing)
|
||||
Remove ();
|
||||
else
|
||||
Source.Remove (ID);
|
||||
}
|
||||
|
||||
public bool Handler ()
|
||||
{
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue