Reputation: 923
I would like to test a Qt piece of code that is using signals/slots with std::shared_ptr as parameters.
My issue is that the QSignalSpy class, that works well for all the other type of parameters, does not seem to play nice when it comes to use standard shared pointers. Indeed, the takeFirst method returns a list of QVariant. I can convert the argument to a shared_ptr doing something like that:
QVERIFY(arguments.at(0).value<std::shared_ptr<Canard>>() == canardInstance); // verify the first argument
But then I end up with 2 smart pointers referencing the same heap memory, and it crashes when going out of the current scope. Is there a way to use QSignalSpy in my case ?
Thanks !
Upvotes: 0
Views: 376
Reputation: 923
Actually I missed completely the point. It was working fine (meaning the reference counting is working as expected) but I got a memory corruption for another reason. I tried using QSharedPointer and get the same behavior.
Upvotes: 1