The Q*Application instance should be destroyed before main() returns
S3 - Major
This came up discussing an issue that came up using mscore with a 3rd party Qt plugin not directly related to mscore itself on the Qt interest ML.
Qt assumes that the QCoreApplication instance is destroyed before main() returns; doing this resets qApp to nullptr. Any plugin accessing the instance via qApp during global destruction as part of its cleanup work is likely to access memory that has become invalid and provoke a crash.
While my exact way of triggering this isn't likely to be encountered by many other users it's still a dormant bug that should be addressed.
> Qt assumes that the QCoreApplication instance is destroyed before main() returns
Could you please provide a reference for this? I have not encountered any statement on this in Qt docs, nor have I seen any issues resulting from this. Moreover, Qt documentation says that
exec()function may not return at all so anything that resides after
qApp->exec()call may happen to be not executed at all.
The info comes from Thiago Macieira whom I've come to know as one of the references on this kind of thing:
Most code I've seen create the Q*Application instance as a local variable that is destroyed when it goes out of scope. I suppose you could do something like
QPointer app = MuseScoreApplication::initApplication(argc, av);
(I'm not getting this to format correctly; you should get the intended code when you quote this, sorry).