Skip to content

Commit

Permalink
[NUI] Block native callback if window is disposed or disposing
Browse files Browse the repository at this point in the history
  • Loading branch information
JoogabYun committed Dec 2, 2024
1 parent 5621d67 commit 9ed53a7
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/Tizen.NUI/src/public/Window/WindowEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,12 @@ private void OnWindowFocusedChanged(IntPtr window, bool focusGained)

private bool OnWindowTouch(IntPtr view, IntPtr touchData)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

if (touchData == global::System.IntPtr.Zero)
{
NUILog.Error("touchData should not be null!");
Expand All @@ -1069,6 +1075,12 @@ private bool OnWindowTouch(IntPtr view, IntPtr touchData)

private bool OnWindowInterceptTouch(IntPtr view, IntPtr touchData)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

if (touchData == global::System.IntPtr.Zero)
{
NUILog.Error("touchData should not be null!");
Expand All @@ -1087,6 +1099,12 @@ private bool OnWindowInterceptTouch(IntPtr view, IntPtr touchData)

private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

if (wheelEvent == global::System.IntPtr.Zero)
{
NUILog.Error("wheelEvent should not be null!");
Expand All @@ -1104,6 +1122,12 @@ private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)

private bool OnWindowInterceptWheel(IntPtr view, IntPtr wheelEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

if (wheelEvent == global::System.IntPtr.Zero)
{
NUILog.Error("wheelEvent should not be null!");
Expand All @@ -1123,6 +1147,12 @@ private bool OnWindowInterceptWheel(IntPtr view, IntPtr wheelEvent)
// Callback for Stage KeyEventsignal
private void OnStageKey(IntPtr data)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return;
}

if (stageKeyHandler != null)
{
KeyEventArgs e = new KeyEventArgs();
Expand All @@ -1135,6 +1165,12 @@ private void OnStageKey(IntPtr data)
// Callback for Stage InterceptKeyEventsignal
private bool OnStageInterceptKey(IntPtr data)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

bool consumed = false;
if (stageInterceptKeyHandler != null)
{
Expand Down Expand Up @@ -1266,6 +1302,12 @@ private void OnKeyboardRepeatSettingsChanged()

private void OnWindowMouseInOutEvent(IntPtr view, IntPtr mouseEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return;
}

if (mouseEvent == global::System.IntPtr.Zero)
{
NUILog.Error("mouseEvent should not be null!");
Expand Down Expand Up @@ -1312,6 +1354,12 @@ private void OnResizeCompleted(IntPtr window, IntPtr size)

private void OnWindowMouseRelativeEvent(IntPtr view, IntPtr mouseEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return;
}

if (mouseEvent == global::System.IntPtr.Zero)
{
NUILog.Error("mouseEvent should not be null!");
Expand All @@ -1328,6 +1376,12 @@ private void OnWindowMouseRelativeEvent(IntPtr view, IntPtr mouseEvent)

private void OnWindowPointerConstraintsEvent(IntPtr view, IntPtr constraintsEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return;
}

if (constraintsEvent == global::System.IntPtr.Zero)
{
NUILog.Error("constraintsEvent should not be null!");
Expand All @@ -1344,6 +1398,12 @@ private void OnWindowPointerConstraintsEvent(IntPtr view, IntPtr constraintsEven

private bool OnWindowHover(IntPtr view, IntPtr hoverData)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return false;
}

if (hoverData == global::System.IntPtr.Zero)
{
NUILog.Error("hoverData should not be null!");
Expand Down Expand Up @@ -1688,6 +1748,12 @@ public EffectType Type

private void OnDetentEvent(IntPtr wheelEvent)
{
if (Disposed || IsDisposeQueued)
{
// Ignore native callback if the window is disposed or queued for disposal.
return;
}

WheelEventArgs e = new WheelEventArgs();

if (wheelEvent != global::System.IntPtr.Zero)
Expand Down

0 comments on commit 9ed53a7

Please sign in to comment.