mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 19:15:34 +00:00
Generalized Idle and Timeout, fixed Timeout.Add (#289)
Idle.Add, Idle.AddSeconds, Timeout.Add, Timeout.AddSeconds methods overloads are generalized: * no priority (for default priority) * enum priority (for standard priorities) * int priority (for custom priority) * overloads call main method with int priority Fixed leak in Timeout.Add(priority): method was not using userData and DestroyHelper.NotifyHandler.
This commit is contained in:
parent
0ec20fa7cd
commit
bc5674ae06
|
@ -86,6 +86,11 @@ namespace GLib {
|
||||||
return p.ID;
|
return p.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static uint Add (Priority priority, IdleHandler hndlr)
|
||||||
|
{
|
||||||
|
return Add ((int)priority, hndlr);
|
||||||
|
}
|
||||||
|
|
||||||
public static uint Add (IdleHandler hndlr)
|
public static uint Add (IdleHandler hndlr)
|
||||||
{
|
{
|
||||||
return Add ((int)Priority.DefaultIdle, hndlr);
|
return Add ((int)Priority.DefaultIdle, hndlr);
|
||||||
|
@ -97,5 +102,3 @@ namespace GLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,15 @@ namespace GLib {
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
delegate uint d_g_timeout_add_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
|
delegate uint d_g_timeout_add_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
|
||||||
static d_g_timeout_add_full g_timeout_add_full = FuncLoader.LoadFunction<d_g_timeout_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_full"));
|
static d_g_timeout_add_full g_timeout_add_full = FuncLoader.LoadFunction<d_g_timeout_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_full"));
|
||||||
public static uint Add (uint interval, TimeoutHandler hndlr)
|
|
||||||
|
public static uint Add (uint interval, TimeoutHandler hndlr, int priority)
|
||||||
{
|
{
|
||||||
TimeoutProxy p = new TimeoutProxy (hndlr);
|
TimeoutProxy p = new TimeoutProxy (hndlr);
|
||||||
lock (p)
|
lock (p)
|
||||||
{
|
{
|
||||||
var gch = GCHandle.Alloc(p);
|
var gch = GCHandle.Alloc(p);
|
||||||
var userData = GCHandle.ToIntPtr(gch);
|
var userData = GCHandle.ToIntPtr(gch);
|
||||||
p.ID = g_timeout_add_full (0, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler);
|
p.ID = g_timeout_add_full (priority, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.ID;
|
return p.ID;
|
||||||
|
@ -83,39 +84,44 @@ namespace GLib {
|
||||||
|
|
||||||
public static uint Add (uint interval, TimeoutHandler hndlr, Priority priority)
|
public static uint Add (uint interval, TimeoutHandler hndlr, Priority priority)
|
||||||
{
|
{
|
||||||
TimeoutProxy p = new TimeoutProxy (hndlr);
|
return Add (interval, hndlr, (int)priority);
|
||||||
lock (p)
|
}
|
||||||
{
|
|
||||||
var gch = GCHandle.Alloc(p);
|
|
||||||
var userData = GCHandle.ToIntPtr(gch);
|
|
||||||
p.ID = g_timeout_add_full ((int)priority, interval, (TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.ID;
|
public static uint Add (uint interval, TimeoutHandler hndlr)
|
||||||
|
{
|
||||||
|
return Add (interval, hndlr, (int)Priority.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
delegate uint d_g_timeout_add_seconds_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
|
delegate uint d_g_timeout_add_seconds_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
|
||||||
static d_g_timeout_add_seconds_full g_timeout_add_seconds_full = FuncLoader.LoadFunction<d_g_timeout_add_seconds_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_seconds_full"));
|
static d_g_timeout_add_seconds_full g_timeout_add_seconds_full = FuncLoader.LoadFunction<d_g_timeout_add_seconds_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_seconds_full"));
|
||||||
|
|
||||||
public static uint AddSeconds (uint interval, TimeoutHandler hndlr)
|
public static uint AddSeconds (uint interval, TimeoutHandler hndlr, int priority)
|
||||||
{
|
{
|
||||||
TimeoutProxy p = new TimeoutProxy (hndlr);
|
TimeoutProxy p = new TimeoutProxy (hndlr);
|
||||||
lock (p)
|
lock (p)
|
||||||
{
|
{
|
||||||
var gch = GCHandle.Alloc(p);
|
var gch = GCHandle.Alloc(p);
|
||||||
var userData = GCHandle.ToIntPtr(gch);
|
var userData = GCHandle.ToIntPtr(gch);
|
||||||
p.ID = g_timeout_add_seconds_full (0, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler);
|
p.ID = g_timeout_add_seconds_full (priority, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.ID;
|
return p.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static uint AddSeconds (uint interval, TimeoutHandler hndlr, Priority priority)
|
||||||
|
{
|
||||||
|
return AddSeconds (interval, hndlr, (int)priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint AddSeconds (uint interval, TimeoutHandler hndlr)
|
||||||
|
{
|
||||||
|
return AddSeconds (interval, hndlr, (int)Priority.Default);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Remove (uint id)
|
public static void Remove (uint id)
|
||||||
{
|
{
|
||||||
Source.Remove (id);
|
Source.Remove (id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue