[Interest] QApplication was not created in the main() thread.

Thiago Macieira thiago.macieira at intel.com
Mon Jul 3 06:50:40 CEST 2023


On Saturday, 1 July 2023 06:37:20 PDT Yauheni Pervenenka via Interest wrote:
> Hi, Konstantin, thanks for your reply, I have attached stack when QObject
> created first time, the problem is that UB is already exists in Qt,

No, it doesn't.

> Q_CONSTRUCTOR_FUNCTION(initialize) and QBasicAtomicPointer<QThread>
> QCoreApplicationPrivate::theMainThread =
> Q_BASIC_ATOMIC_INITIALIZER(nullptr);
> should be called in next order, first should be initialized theMainThread
> and after should be called Q_CONSTRUCTOR_FUNCTION(initialize) but it is not
> guaranteed by standard, https://en.cppreference.com/w/cpp/language/siof

Nope. The QBasicAtomicPointer is initialised at static time, meaning it is 
initialised *before* any code runs. It's guaranteed by the standard.

Your diagnosis is incorrect.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230702/7964e4be/attachment.bin>


More information about the Interest mailing list