Page 1 of 1

DynamicTextureSource crash in callback after deletion

Posted: 15 Jan 2025, 11:56
by Mikhail Yanakayev
Hello,
We're using class inherited from DynamicTextureSource with callback on texture rendering. Problem is after this class deletion callback can still be called with garbage pointer inside second parameter. What's right procedure of deletion such classes with proper callback call cancellation?
Code below:
MyDynamicTextureSource::MyDynamicTextureSource(uint32_t width, uint32_t height) :
	Noesis::DynamicTextureSource(width, height, &DynamicTextureSourceCallback, this),
{
}

MyDynamicTextureSource::~MyDynamicTextureSource()
{
}

Noesis::Texture* MyTextureSource::DynamicTextureSourceCallback(Noesis::RenderDevice* device, void* user)
{
	DragonDynamicTextureSource* source = (DragonDynamicTextureSource*)user;
	Noesis::Visual* visual = Noesis::DynamicCast<Noesis::Visual*>(source->GetNodeParent()); //crash here

	MyRender(visual);
}
Thanks!

Re: DynamicTextureSource crash in callback after deletion

Posted: 16 Jan 2025, 10:44
by jsantos
Could you please create a ticket for this? This was partially fixed in the Studio branch but we do still need a better solution.

Re: DynamicTextureSource crash in callback after deletion

Posted: 16 Jan 2025, 12:50
by Mikhail Yanakayev
Sure. Ticked has been created:
https://www.noesisengine.com/bugs/view.php?id=3906

Is there a chance that crash will not occur in 3.2.7 version? Or some workaround already exists maybe?

Re: DynamicTextureSource crash in callback after deletion

Posted: 20 Jan 2025, 12:50
by jsantos
Let's continue the conversation in the created ticket. Your usage of DynamicTextureSource is not correct and we need to find an alternative.