In a shared library (.so) I define a std::shared_ptr to a class object which is returned to the caller accross the library boundary to the main routine which is a Qt5.4 project. There the pointer is used in a if statement. As the bool operation is the last owner of the shared pointer it is deleted after finishing this operation and the destructor is called.
.so file (an Autotools-project):
# define STD_SHARED_PTR std::shared_ptr
typedef STD_SHARED_PTR<RenderingControl> RDCH;
RDCH MediaRenderer::rdc() {
RDCH rdcl = RDCH(new RenderingControl(*desc(), *it));
long foo = rdcl.use_count();
m->rdc = rdcl; //rdc is defined as std::weak_ptr
return rdcl;
}
.cpp (a Qt5.4 project):
typedef STD_SHARED_PTR<RenderingControl> MRDH;
MRDH renderer = MRDH(new MediaRenderer(ddesc));
if (renderer->rdc()) {
...
return;
}
Everything works fine on a x86 machine compiled with either Qt4.8 or Qt5.4. The destructor is called after finishing the if statement. Cross compiled for an ARM (Raspberry Pi 2) using Qt5.4, however, the destructor is not called. If I additionally check the use_count() it yields 1 in both the .so and the .cpp file on the x86, but 1 in the .so and 0 in the .cpp for the ARM.
If I compile on ARM using Qt4.8 everything is fine on ARM, too.
Thank you!
Aucun commentaire:
Enregistrer un commentaire