qaxserver: Create QApplication before QAxFactory in DLL case
QAxFactory inherits QObject, but Qt does not support creating QObjects
before QCoreApplication. In the in-process DLL server case, COM may
invoke DllGetClassObject on the COM apartment thread before the host
application has created QApplication. This causes the COM thread to be
recorded as Qt's main thread, leading to a mismatch when QApplication
is later created on a different thread.
Fix this by creating QApplication in qAxFactory() when none exists and
qAxIsServer is true. The qAxIsServer flag is set by DllMain before any
COM entry points can fire, so this condition reliably identifies the
in-process DLL path. The EXE paths are unaffected: qAxIsServer is still
false when qAxFactory() is first reached from qax_startServer(), and
both the factory and QApplication are created on the same thread anyway.
Fixes: QTBUG-146190
Pick-to: 6.11 6.8
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Change-Id: I3b61073d3520f1f0e77ada2c8807b7fa51037cb7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Miguel Costa <miguel.costa@qt.io>