d.stepanov
Topic Author
Posts: 4
Joined: 03 Jun 2025, 12:53

Lifetime of BaseRefCounted class fields

23 Sep 2026, 16:34

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?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Lifetime of BaseRefCounted class fields

24 Sep 2026, 14:25

Hello! If you’re talking about the delegates we have in a few samples that are not allocated on the heap:
private:
  NoesisApp::DelegateCommand _startCommand;
  NoesisApp::DelegateCommand _settingsCommand;
  NoesisApp::DelegateCommand _exitCommand;
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.

Who is online

Users browsing this forum: No registered users and 14 guests