Crash when releasing IView object
Posted: 14 Aug 2017, 05:12
Hi,
I've implemented NoesisGUI with Urho3D and some of the samples (ImageAtlas.xaml and Palette.xaml) crashes the program during the destruction (mPtr->Release()) of the xamlView Ptr.
I compiled the D3D11 sample that came with the package and no crash ocurred. I couldn't find anything in the docs but do I need to do additional cleanup/handling of noesis objects ?
Here's the code I'm using:
I've implemented NoesisGUI with Urho3D and some of the samples (ImageAtlas.xaml and Palette.xaml) crashes the program during the destruction (mPtr->Release()) of the xamlView Ptr.
I compiled the D3D11 sample that came with the package and no crash ocurred. I couldn't find anything in the docs but do I need to do additional cleanup/handling of noesis objects ?
Here's the code I'm using:
Code: Select all
Game::Game(Context* context) :
Application(context),
scene_(nullptr)
{
// NoesisGUI is initialized here. Resources will be loaded from current working directory
Noesis::GUI::Init(NoesisErrorHandler);
Noesis::GUI::SetResourceProvider(".");
}
Game::~Game()
{
// Shutdown Noesis Engine
Noesis::GUI::Shutdown();
}
void Game::Start()
{
Graphics* graphics = this->GetSubsystem<Graphics>(); // Urho3D Graphics Object
// --------------------------------------------------
// Noesis Context Initialization
Noesis::Ptr<Noesis::D3D11RenderDevice> nsDevice = *new Noesis::D3D11RenderDevice(graphics->GetImpl()->GetDeviceContext());
Noesis::Ptr<Noesis::VGContext> nsContext = Noesis::GUI::CreateVGContext(nsDevice.GetPtr(), Noesis::VGOptions());
// Noesis Views
Noesis::Ptr<Noesis::FrameworkElement> mainXaml = Noesis::GUI::LoadXaml<Noesis::FrameworkElement>("Samples\\ImageAtlas.xaml");
this->nsMainView = Noesis::GUI::CreateView(mainXaml.GetPtr());
this->nsMainView->GetRenderer()->Init(nsContext.GetPtr());
this->nsMainView->SetSize(graphics->GetWidth(), graphics->GetHeight());
this->nsMainView->SetAntialiasingMode(Noesis::AntialiasingMode::AntialiasingMode_PPAA);
// --------------------------------------------------
// Urho3D stuff
// ...
}
void Game::Stop()
{
this->nsMainView.Reset();
}
// ======================================================================
// Core events
// ======================================================================
void Game::OnUpdate(StringHash type, VariantMap &args)
{
static double timestep = 0;
timestep += args[Update::P_TIMESTEP].GetFloat();
this->nsMainView->Update(timestep);
}
// ======================================================================
// Graphics events
// ======================================================================
void Game::OnScreenMode(StringHash type, VariantMap &args)
{
int width = args[ScreenMode::P_WIDTH].GetInt();
int height = args[ScreenMode::P_HEIGHT].GetInt();
// ...
this->nsMainView->SetSize(width, height);
}
void Game::OnBeginRendering(StringHash type, VariantMap &args)
{
// Performs rendering operations.
Noesis::IRenderer* nsRenderer = this->nsMainView->GetRenderer();
// Applies changes to the render tree
nsRenderer->UpdateRenderTree();
// Renders offscreen textures. This step must be done before binding the main render target
if (nsRenderer->NeedsOffscreen())
{
nsRenderer->RenderOffscreen();
}
}
void Game::OnEndRendering(StringHash type, VariantMap &args)
{
this->nsMainView->GetRenderer()->Render();
}