how to keep pointer on the Data Writer ?

2 posts / 0 new
Last post
Last seen: 3 years 4 months ago
Joined: 12/19/2018
Posts: 2
how to keep pointer on the Data Writer ?

I have some class that hold pointer on the data writer. 

On my init function i fine the data writer by name - and i set the pointer to this data writer. 

Now, when i try to use this pointer -- i get exception that the writer is close. 

when i check the address value i see that its valid address and not null. 

what to do ? 

( code is modern C++ ) 

Last seen: 1 hour 7 min ago
Joined: 10/22/2018
Posts: 81

Hi Yanshof,

Could you share the relevant snippets of code?

One thing that comes to mind is that it might be necessary to call  retain() on the DataWriter.
Explained here,
the DataWriter entity may be being destroyed if there are no references to it.

If you do use DataWriter.retain(), you will need to call  DataWriter.close() when you want to destroy it (as it will no longer be automatically destroyed).