mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-08 16:03:21 +02:00
2003-10-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* gtk/ThreadNotify.cs: close the pipe and detach the GSource when explicitly requested or finalized. svn path=/trunk/gtk-sharp/; revision=19142
This commit is contained in:
parent
ca54b617d6
commit
971b309120
@ -1,3 +1,8 @@
|
||||
2003-10-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||
|
||||
* gtk/ThreadNotify.cs: close the pipe and detach the GSource when
|
||||
explicitly requested or finalized.
|
||||
|
||||
2003-10-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||
|
||||
* gconf/tools/schemagen.cs: support for lists.
|
||||
|
@ -23,13 +23,13 @@ namespace Gtk {
|
||||
/// </summary>
|
||||
/// <remarks/>
|
||||
///
|
||||
public class ThreadNotify {
|
||||
public class ThreadNotify : IDisposable {
|
||||
|
||||
//
|
||||
// DllImport functions from Gtk
|
||||
//
|
||||
[DllImport ("libgtk-win32-2.0-0.dll")]
|
||||
private static extern int gdk_input_add (int s, int cond, GdkInputFunction f, IntPtr data);
|
||||
private static extern uint gdk_input_add (int s, int cond, GdkInputFunction f, IntPtr data);
|
||||
public delegate void GdkInputFunction (IntPtr data, int source, int cond);
|
||||
|
||||
//
|
||||
@ -44,9 +44,13 @@ namespace Gtk {
|
||||
[DllImport ("libc.so.6")]
|
||||
private static extern unsafe int write (int fd, byte *b, int count);
|
||||
|
||||
[DllImport ("libc.so.6")]
|
||||
private static extern int close (int fd);
|
||||
|
||||
GdkInputFunction notify_pipe;
|
||||
int [] pipes;
|
||||
bool disposed;
|
||||
uint tag;
|
||||
|
||||
ReadyEvent re;
|
||||
|
||||
@ -59,7 +63,7 @@ namespace Gtk {
|
||||
notify_pipe = new GdkInputFunction (NotifyPipe);
|
||||
pipes = new int [2];
|
||||
pipe (pipes);
|
||||
gdk_input_add (pipes [0], 1, notify_pipe, (IntPtr) 0);
|
||||
tag = gdk_input_add (pipes [0], 1, notify_pipe, (IntPtr) 0);
|
||||
this.re = re;
|
||||
}
|
||||
|
||||
@ -96,5 +100,34 @@ namespace Gtk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Close ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
~ThreadNotify ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose ()
|
||||
{
|
||||
Close ();
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposed) {
|
||||
disposed = true;
|
||||
GLib.Source.Remove (tag);
|
||||
close (pipes [1]);
|
||||
close (pipes [0]);
|
||||
}
|
||||
|
||||
pipes = null;
|
||||
notify_pipe = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user