Skip to content

Instantly share code, notes, and snippets.

@jpankalainen
Last active August 30, 2021 06:48
Show Gist options
  • Save jpankalainen/8385cfccce3b81fd0dfdb860e7461aa5 to your computer and use it in GitHub Desktop.
Save jpankalainen/8385cfccce3b81fd0dfdb860e7461aa5 to your computer and use it in GitHub Desktop.
Repro for ObjectsChanged Reload notice issue
#include <iostream>
#include "pxr/pxr.h"
#include "pxr/usd/usd/stage.h"
#include "pxr/usd/usd/references.h"
#include "pxr/usd/usd/notice.h"
class StageListener : public pxr::TfWeakBase
{
public:
void OnNotice( const pxr::UsdNotice::ObjectsChanged& notice, const pxr::UsdStageWeakPtr& sender )
{
//notice is broken here after stage->Reload
for( const pxr::SdfPath& path : notice.GetChangedInfoOnlyPaths() )
{
for( const pxr::TfToken& field : notice.GetChangedFields( path ) )
{
std::cout << field.GetString();
}
}
}
};
int main()
{
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory( "Stage" );
StageListener listener;
pxr::TfWeakPtr< StageListener > pListener = pxr::TfCreateWeakPtr( &listener );
pxr::TfNotice::Register( pListener, &StageListener::OnNotice, stage );
pxr::UsdPrim prim = stage->DefinePrim( pxr::SdfPath( "/Root" ) );
stage->Reload();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment