janbar / noson

C++ library for accessing SONOS devices.
GNU General Public License v3.0
27 stars 9 forks source link

:ConnectZone terminate with 'std::bad_alloc' #7

Closed daniwebCH closed 5 years ago

daniwebCH commented 5 years ago

I get this: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

THis occurs when I make a discover and I call l bool System::ConnectZone(const ZonePtr& zone, void* CBHandle, EventCB eventCB) I see that a new Player(zone, m_eventHandler, CBHandle, eventCB) is connected.

What shall I do to prevent it ? Would it be a good idea in System::ConnectZone to destry an eventual player stored at m_connectedZone.player ?

janbar commented 5 years ago

Any more details ? A gdb stack trace or a snippet of your code ...

janbar commented 5 years ago

Would it be a good idea in System::ConnectZone to destry an eventual player stored at m_connectedZone.player ?

It is a shared pointer (PlayerPtr) and it will be destroy under the hood once no longer referenced. In noson all types "*Ptr" are shared pointer and you haven't need to handle freeing.