fix: add null safety checks to UIView lifecycle methods
- Add this == null guard in Initialize() to prevent NullReferenceException after MonoBehaviour destruction - Add this == null guard in Release() for consistent safety across lifecycle methods - Prevent crashes when UI views are accessed during or after object destruction Исправлена безопасность при работе с UIView: - Добавлена проверка this == null в Initialize() для предотвращения NullReferenceException после уничтожения MonoBehaviour - Добавлена проверка this == null в Release() для согласованной безопасности во всех методах жизненного цикла - Предотвращены краши при обращении к UI видам во время или после разрушения объектов
This commit is contained in:
@@ -8,6 +8,11 @@ namespace QuizPleaseTest.Common.UI
|
|||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
|
if (this == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_isInitialized)
|
if (_isInitialized)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -19,6 +24,11 @@ namespace QuizPleaseTest.Common.UI
|
|||||||
|
|
||||||
public virtual void Release()
|
public virtual void Release()
|
||||||
{
|
{
|
||||||
|
if (this == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_isInitialized)
|
if (!_isInitialized)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user