-
- d.stepanov
- Posts: 4
- Joined:
Lifetime of BaseRefCounted class fields
Hi! Official examples expose raw pointers to instances of BaseRefCounted fields of view models to the view. It does not look right, because any control can create Noesis::Ptr from such raw pointer which will call delete this; and thus will lead to subtle bugs and crashes. In our project we're indeed experience such random (and somewhat rare) crashes which affects our overall crash-rate which negatively impacts our project in app stores.
For example, the most common place of crashes are commands. If a command instance is stored directly as a field (not allocated on heap), exposed to reflection as a raw pointer via getter it will cause crash in some cases. The obvious fix for this issue is indeed to use Noesis::Ptr + Noesis::MakePtr . So what's your opinion on this issue?
For example, the most common place of crashes are commands. If a command instance is stored directly as a field (not allocated on heap), exposed to reflection as a raw pointer via getter it will cause crash in some cases. The obvious fix for this issue is indeed to use Noesis::Ptr + Noesis::MakePtr . So what's your opinion on this issue?
Re: Lifetime of BaseRefCounted class fields
Hello! If you’re talking about the delegates we have in a few samples that are not allocated on the heap:
You’re absolutely right. This is extremely dangerous, and it’s probably an optimization that isn’t worth the risk. Please create a ticket for it.
Code: Select all
private:
NoesisApp::DelegateCommand _startCommand;
NoesisApp::DelegateCommand _settingsCommand;
NoesisApp::DelegateCommand _exitCommand;
Who is online
Users browsing this forum: No registered users and 14 guests