This simple code crashes on program end (Qt 5.9.1, gcc 5.4.1):
#include <QCoreApplication>
#include <memory>
std::shared_ptr<QCoreApplication> manager;
int main(int argc, char *argv[])
{
manager = std::make_shared<QCoreApplication>(argc, argv);
}
I know that the usual way is to declare a QCoreApplication instance on the stack, and have it destroyed at the end of main(), but my use case is as follows: I am wrapping a library that makes use of Qt with Boost.Python, and I initialize Qt like above when the python module gets loaded. However, I have no way to destroy the QCoreApplication unless I force the user to call some finalize() method.
The idea was then to have it destroyed when the library (python module) gets unloaded, but this does not seem to work. Is the above expected, and if so, why? "Destruction order problem" is my first guess, but in this case, should this be regarded as a bug?