From fbe7b7d35b8d26ef1c8647face08a6b188e8a5c2 Mon Sep 17 00:00:00 2001 From: Tim Fowler Date: Wed, 15 Apr 2020 13:17:31 -0400 Subject: [PATCH 1/2] MAYA-101454 Clear stage cach on file new/open. --- lib/mayaUsd/listeners/notice.cpp | 13 +++++++++++++ plugin/adsk/plugin/plugin.cpp | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/lib/mayaUsd/listeners/notice.cpp b/lib/mayaUsd/listeners/notice.cpp index bb011074e2..a6016b7e2f 100644 --- a/lib/mayaUsd/listeners/notice.cpp +++ b/lib/mayaUsd/listeners/notice.cpp @@ -24,6 +24,11 @@ PXR_NAMESPACE_OPEN_SCOPE namespace { +// Siple ref count for how many plugins have initialized the callback. +// Used to keep the listener around until the last plugin asks for it +// to be removed. +static int _newOrOpenRegistrationCount = 0; + static void _OnMayaNewOrOpenSceneCallback(void* /*clientData*/) @@ -53,6 +58,10 @@ UsdMayaSceneResetNotice::UsdMayaSceneResetNotice() void UsdMayaSceneResetNotice::InstallListener() { + if (_newOrOpenRegistrationCount++ > 0) { + return; + } + // Send scene reset notices when changing scenes (either by switching // to a new empty scene or by opening a different scene). We do not listen // for kSceneUpdate messages since those are also emitted after a SaveAs @@ -79,6 +88,10 @@ UsdMayaSceneResetNotice::InstallListener() void UsdMayaSceneResetNotice::RemoveListener() { + if (_newOrOpenRegistrationCount-- > 1) { + return; + } + if (_afterNewCallbackId != 0) { MMessage::removeCallback(_afterNewCallbackId); } diff --git a/plugin/adsk/plugin/plugin.cpp b/plugin/adsk/plugin/plugin.cpp index 13007dd27b..c65adf2460 100644 --- a/plugin/adsk/plugin/plugin.cpp +++ b/plugin/adsk/plugin/plugin.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -134,6 +135,8 @@ MStatus initializePlugin(MObject obj) } } + UsdMayaSceneResetNotice::InstallListener(); + return status; } @@ -180,5 +183,7 @@ MStatus uninitializePlugin(MObject obj) CHECK_MSTATUS(status); #endif + UsdMayaSceneResetNotice::RemoveListener(); + return status; } From 2e785ee2c1fb4a1a1dabbcc383dbf520d9400d15 Mon Sep 17 00:00:00 2001 From: Tim Fowler Date: Thu, 16 Apr 2020 20:08:56 -0400 Subject: [PATCH 2/2] typo fix --- lib/mayaUsd/listeners/notice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/listeners/notice.cpp b/lib/mayaUsd/listeners/notice.cpp index a6016b7e2f..6f7d433113 100644 --- a/lib/mayaUsd/listeners/notice.cpp +++ b/lib/mayaUsd/listeners/notice.cpp @@ -24,7 +24,7 @@ PXR_NAMESPACE_OPEN_SCOPE namespace { -// Siple ref count for how many plugins have initialized the callback. +// Simple ref count for how many plugins have initialized the callback. // Used to keep the listener around until the last plugin asks for it // to be removed. static int _newOrOpenRegistrationCount = 0;