{
Interop.Evas.evas_object_size_hint_weight_set(Handle, 1.0, 1.0);
Interop.Elementary.elm_win_conformant_set(parent.Handle, true);
- Interop.Elementary.elm_win_resize_object_add(parent.Handle, Handle);
+ parent.AddResizeObject(this);
}
protected override IntPtr CreateHandle(EvasObject parent)
OnInstantiated();
}
+ // C# Finalizer was called on GC thread
+ // So, We can't access to EFL object
+ // And When Finalizer was called, Field can be already released.
+ //~EvasObject()
+ //{
+ // Unrealize();
+ //}
+
public event EventHandler Deleted;
public event EventHandler<EvasKeyEventArgs> KeyUp;
public event EventHandler<EvasKeyEventArgs> KeyDown;
Interop.Evas.evas_object_size_hint_weight_set(Handle, x, y);
}
- ~EvasObject()
- {
- Unrealize();
- }
-
public void Show()
{
Interop.Evas.evas_object_show(Handle);
Deleted?.Invoke(this, EventArgs.Empty);
OnInvalidate();
Handle = IntPtr.Zero;
+
+ (Parent as Window)?.RemoveChild(this);
+ Parent = null;
_deleted = null;
}
Parent = parent;
Handle = CreateHandle(parent);
Debug.Assert(Handle != IntPtr.Zero);
+
+ (parent as Window)?.AddChild(this);
+
OnRealized();
_deleted = new Interop.EvasObjectEvent(this, Handle, Interop.Evas.ObjectCallbackType.Del);
_keydown = new Interop.EvasObjectEvent<EvasKeyEventArgs>(this, Handle, Interop.Evas.ObjectCallbackType.KeyDown, EvasKeyEventArgs.Create);
if (IsRealized)
{
OnUnrealize();
- Interop.Evas.evas_object_del(Handle);
+ IntPtr toBeDeleted = Handle;
Handle = IntPtr.Zero;
- Parent = null;
+ _deleted?.Dispose();
_deleted = null;
+ _keydown?.Dispose();
+ _keydown = null;
+ _keyup?.Dispose();
+ _keyup = null;
+ _moved?.Dispose();
+ _moved = null;
+ _resized?.Dispose();
+ _resized = null;
+ _renderPost?.Dispose();
+ _renderPost = null;
+
+ (Parent as Window)?.RemoveChild(this);
+
+ Interop.Evas.evas_object_del(toBeDeleted);
+ Parent = null;
}
}
}
Handle = handle;
}
- ~ItemObject()
- {
- if (Handle != IntPtr.Zero)
- Interop.Elementary.elm_object_item_del(Handle);
- }
+ // C# Finalizer was called on GC thread
+ // So, We can't access to EFL object
+ // And When Finalizer was called, Field can be already released.
+ //~ItemObject()
+ //{
+ // if (Handle != IntPtr.Zero)
+ // Interop.Elementary.elm_object_item_del(Handle);
+ //}
public int Id { get; private set; }
{
Interop.SmartEvent _deleteRequest;
Interop.SmartEvent _rotationChanged;
+ HashSet<EvasObject> _referenceHolder = new HashSet<EvasObject>();
public Window(string name) : this(null, name)
{
return Interop.Elementary.elm_win_add(parent != null ? parent.Handle : IntPtr.Zero, Name, 0);
}
+ internal void AddChild(EvasObject obj)
+ {
+ _referenceHolder.Add(obj);
+ }
+
+ internal void RemoveChild(EvasObject obj)
+ {
+ _referenceHolder.Remove(obj);
+ }
+
static int[] ConvertDegreeArray(DisplayRotation value)
{
List<int> rotations = new List<int>();
{
if (disposing)
{
- foreach (var cb in _nativeCallbacks)
- {
- Evas.evas_object_event_callback_del(_handle, _type, cb.callback);
- }
+ // Place holder to dispose managed state (managed objects).
+ }
+ foreach (var cb in _nativeCallbacks)
+ {
+ Evas.evas_object_event_callback_del(_handle, _type, cb.callback);
}
_nativeCallbacks.Clear();
_disposed = true;
{
if (disposing)
{
- foreach (var cb in _nativeCallbacks)
- {
- Evas.evas_object_event_callback_del(_handle, _type, cb.callback);
- }
+ // Place holder to dispose managed state (managed objects).
+ }
+ foreach (var cb in _nativeCallbacks)
+ {
+ Evas.evas_object_event_callback_del(_handle, _type, cb.callback);
}
_nativeCallbacks.Clear();
_disposed = true;
{
if (disposing)
{
- foreach (var cb in _nativeCallbacks)
- {
- Evas.evas_object_smart_callback_del(_handle, _eventName, cb.callback);
- }
+ // Place holder to dispose managed state (managed objects).
+ }
+ foreach (var cb in _nativeCallbacks)
+ {
+ Evas.evas_object_smart_callback_del(_handle, _eventName, cb.callback);
}
_nativeCallbacks.Clear();
}
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
}
{
if (disposing)
{
- foreach (var cb in _nativeCallbacks)
- {
- Evas.evas_object_smart_callback_del(_handle, _eventName, cb.callback);
- }
+ // Place holder to dispose managed state (managed objects).
+ }
+ foreach (var cb in _nativeCallbacks)
+ {
+ Evas.evas_object_smart_callback_del(_handle, _eventName, cb.callback);
}
_nativeCallbacks.Clear();
}
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
}
}
if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
{
window.Hide();
+ window.Unrealize();
}
};
}