- Unparent() needs to be excuted in explicit dispose() which is also same as disposing = true.
- Also it should be called prior to before the derived class of View deletes the native handle, otherwise when doing Unparent(), the child itself has empty body (native object has been deleted already).
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(bool disposing)
{
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(bool disposing)
{
- base.Dispose(disposing);
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ Unparent();
+ }
if (accessibilityDelegate != null)
{
if (accessibilityDelegate != null)
{
Marshal.FreeHGlobal(accessibilityDelegatePtr);
accessibilityDelegate = null;
}
Marshal.FreeHGlobal(accessibilityDelegatePtr);
accessibilityDelegate = null;
}
+
+ base.Dispose(disposing);
}
[EditorBrowsable(EditorBrowsableState.Never)]
}
[EditorBrowsable(EditorBrowsableState.Never)]
heightConstraint.Remove();
heightConstraint.Dispose();
}
heightConstraint.Remove();
heightConstraint.Dispose();
}
}
//Release your own unmanaged resources here.
}
//Release your own unmanaged resources here.
/// <since_tizen> 4 </since_tizen>
public override Container GetParent()
{
/// <since_tizen> 4 </since_tizen>
public override Container GetParent()
{
- return this.InternalParent as Container;
+ if (InternalParent)
+ {
+ return this.InternalParent as Container;
+ }
+ return null;
/// Dispose.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// Dispose.
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ // following this guide: https://docs.microsoft.com/ko-kr/dotnet/fundamentals/code-analysis/quality-rules/ca1063?view=vs-2019 (CA1063)
~BaseHandle() => Dispose(false);
/// <summary>
~BaseHandle() => Dispose(false);
/// <summary>