Skip to content

Commit 5cc542c

Browse files
committed
修正 dispose 的调用时机,确保脚本层的出发顺序时正确的
1 parent 024fc72 commit 5cc542c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Assets/Scripts/UI/GComponent.cs

+17-16
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ override protected void CreateDisplayObject()
6666

6767
override public void Dispose()
6868
{
69+
70+
#if FAIRYGUI_TOLUA
71+
if (_peerTable != null)
72+
{
73+
_peerTable.Dispose();
74+
_peerTable = null;
75+
}
76+
#endif
77+
78+
#if FAIRYGUI_PUERTS
79+
if (__onDispose != null)
80+
__onDispose();
81+
__onConstruct = null;
82+
__onDispose = null;
83+
#endif
84+
6985
int cnt = _transitions.Count;
7086
for (int i = 0; i < cnt; ++i)
7187
{
@@ -83,8 +99,6 @@ override public void Dispose()
8399
if (scrollPane != null)
84100
scrollPane.Dispose();
85101

86-
base.Dispose(); //Dispose native tree first, avoid DisplayObject.RemoveFromParent call
87-
88102
cnt = _children.Count;
89103
for (int i = cnt - 1; i >= 0; --i)
90104
{
@@ -93,20 +107,7 @@ override public void Dispose()
93107
obj.Dispose();
94108
}
95109

96-
#if FAIRYGUI_TOLUA
97-
if (_peerTable != null)
98-
{
99-
_peerTable.Dispose();
100-
_peerTable = null;
101-
}
102-
#endif
103-
104-
#if FAIRYGUI_PUERTS
105-
if (__onDispose != null)
106-
__onDispose();
107-
__onConstruct = null;
108-
__onDispose = null;
109-
#endif
110+
base.Dispose(); //Dispose native tree first, avoid DisplayObject.RemoveFromParent call
110111
}
111112

112113
/// <summary>

Assets/Scripts/UI/GGraph.cs

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void SetNativeObject(DisplayObject obj)
100100
_shape = null;
101101
}
102102

103+
if (displayObject != null) displayObject.Dispose();
103104
displayObject = obj;
104105

105106
if (displayObject != null)

0 commit comments

Comments
 (0)