From dcdbc64132f0f02d9d1c0819773ba02de0c8bc10 Mon Sep 17 00:00:00 2001 From: Knox Date: Fri, 13 Dec 2024 15:03:43 +0800 Subject: [PATCH] refine of throttleUpdate usage in the node inspector panel (#18030) --- editor/inspector/contributions/node.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index d22430299a8..c6bc17952bd 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -503,7 +503,7 @@ const Elements = { }, 100, { leading: false, trailing: true }); panel.__nodeChanged__ = (uuid) => { - if (Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) { + if (panel.throttleUpdate && Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) { panel.throttleUpdate(); } }; @@ -548,7 +548,9 @@ const Elements = { } }, 100, { leading: false, trailing: true }); - Profile.on('change', panel.__throttleProfileChanged__); + if (panel.__throttleProfileChanged__) { + Profile.on('change', panel.__throttleProfileChanged__); + } // 识别拖入脚本资源 panel.$.container.addEventListener('dragover', (event) => { @@ -645,15 +647,19 @@ const Elements = { close() { const panel = this; - panel.throttleUpdate.cancel(); + if (panel.throttleUpdate) { + panel.throttleUpdate.cancel(); + } panel.throttleUpdate = undefined; Editor.Message.removeBroadcastListener('scene:change-node', panel.__nodeChanged__); Editor.Message.removeBroadcastListener('scene:animation-time-change', panel.__animationTimeChange__); Editor.Message.removeBroadcastListener('project:setting-change', panel.__projectSettingChanged__); - Profile.removeListener('change', panel.__throttleProfileChanged__); - panel.__throttleProfileChanged__.cancel(); + if (panel.__throttleProfileChanged__) { + Profile.removeListener('change', panel.__throttleProfileChanged__); + panel.__throttleProfileChanged__.cancel(); + } panel.__throttleProfileChanged__ = undefined; }, },