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
2 changed files with 41 additions and 3 deletions
|
@ -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>
|
2003-10-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||||
|
|
||||||
* gconf/tools/schemagen.cs: support for lists.
|
* gconf/tools/schemagen.cs: support for lists.
|
||||||
|
|
|
@ -23,13 +23,13 @@ namespace Gtk {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
///
|
///
|
||||||
public class ThreadNotify {
|
public class ThreadNotify : IDisposable {
|
||||||
|
|
||||||
//
|
//
|
||||||
// DllImport functions from Gtk
|
// DllImport functions from Gtk
|
||||||
//
|
//
|
||||||
[DllImport ("libgtk-win32-2.0-0.dll")]
|
[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);
|
public delegate void GdkInputFunction (IntPtr data, int source, int cond);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -44,9 +44,13 @@ namespace Gtk {
|
||||||
[DllImport ("libc.so.6")]
|
[DllImport ("libc.so.6")]
|
||||||
private static extern unsafe int write (int fd, byte *b, int count);
|
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;
|
GdkInputFunction notify_pipe;
|
||||||
int [] pipes;
|
int [] pipes;
|
||||||
|
bool disposed;
|
||||||
|
uint tag;
|
||||||
|
|
||||||
ReadyEvent re;
|
ReadyEvent re;
|
||||||
|
|
||||||
|
@ -59,7 +63,7 @@ namespace Gtk {
|
||||||
notify_pipe = new GdkInputFunction (NotifyPipe);
|
notify_pipe = new GdkInputFunction (NotifyPipe);
|
||||||
pipes = new int [2];
|
pipes = new int [2];
|
||||||
pipe (pipes);
|
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;
|
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…
Add table
Reference in a new issue