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

Yauheni Pervenenka yauheni.pervenenka at viber.com
Sat Jul 1 15:37:20 CEST 2023


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,
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


On Sat, Jul 1, 2023 at 8:09 AM Konstantin Shegunov <kshegunov at gmail.com>
wrote:

> On Fri, Jun 30, 2023 at 11:12 AM Yauheni Pervenenka via Interest <
> interest at qt-project.org> wrote:
>
>> Hi community,
>> I was faced with a warning QApplication was not created in the main()
>> thread. on windows only, it is very rare happen,
>>
>
> Almost certainly you're creating a static `QObject` instance that sets the
> "main" thread, and whenever the application constructor runs it reports
> this as error.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230701/ab08bf27/attachment.htm>


More information about the Interest mailing list