RT-WDF / rt-wdf_lib

RT-WDF - Real-Time Wave Digital Filter Library
94 stars 21 forks source link

Fix crash on close when deleting the wdfTree in MainComponent dtor #8

Closed KevinArturia closed 8 years ago

KevinArturia commented 8 years ago

Since the nodes are owned by the examples classes (wdfTonestackTree, wdfSwitchTree...) you should only have raw pointer in your wdfTreeNode and wdfPort classes

m-rest commented 8 years ago

Hi @KevinArturia, thanks for your pull request which I will gladly merge! Just one question before: why do you consider the unique_ptr unnecessary and prefer raw pointers?

KevinArturia commented 8 years ago

It is the examples classes which has ownership (and so control the life cycle) of all the nodes. Look at wdfTonestackTree.hpp from line 50 to 67, you have the declaration of all the nodes.

So their is an ownership conflict. You could use shared_ptr but since they will be destroyed when the wdfTonestackTree destructor is called so you don't need to take care of their lifecycle in your tree.

You could even remove the unique_ptr from the example and use object member, it might have better performance because everything will be allocated on the heap and have better cache locality. But that's for a future pull request :).