From 40cbf1927bdd2fa9f531a047d1ba66f68c35d170 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 10 Jun 2015 07:42:42 -0700 Subject: Don't add qmutex_xxx.cpp to SOURCES, as qmutex.cpp #include's them Normally qmake catches the #include and drops the source from SOURCES. But the parser has bugs, so help it by never adding the files. The false: SOURCES += is left so that the sources can be found by Qt Creator. Task-number: QTBUG-46582 Change-Id: I049a653beeb5454c9539ffff13e667877350346b Reviewed-by: Jake Petroules --- src/corelib/thread/thread.pri | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index 3c1ddd984a..2cb00a6cf4 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -46,21 +46,21 @@ SOURCES += thread/qatomic.cpp \ unix:SOURCES += thread/qthread_unix.cpp \ thread/qwaitcondition_unix.cpp -win32:SOURCES += thread/qmutex_win.cpp \ - thread/qthread_win.cpp \ +win32:SOURCES += thread/qthread_win.cpp \ thread/qwaitcondition_win.cpp -integrity:SOURCES += thread/qmutex_unix.cpp \ - thread/qthread_unix.cpp \ +integrity:SOURCES += thread/qthread_unix.cpp \ thread/qwaitcondition_unix.cpp -unix: { - mac { - SOURCES += thread/qmutex_mac.cpp - } else:linux-*:!linux-lsb-* { - SOURCES += thread/qmutex_linux.cpp - } else { - SOURCES += thread/qmutex_unix.cpp - } +false { + # files #included by others, but listed here so IDEs parsing this file know + # they are part of QtCore. Usually, qmake can find out that certain files + # are #included by others and thus remove from SOURCES, but it gets lost + # with qmutex.cpp. + SOURCES += \ + thread/qmutex_linux.cpp \ + thread/qmutex_mac.cpp \ + thread/qmutex_unix.cpp \ + thread/qmutex_win.cpp } -- cgit v1.2.3 From 314c83c0c2f91532654f869b7dc6af1b7e8538da Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 31 Jul 2015 22:55:55 +0200 Subject: Do not use Q_GLOBAL_STATIC in the implementation of QMutex Since Q_GLOBAL_STATIC might use QMutex and cause a stack overflow. Task-number: QTBUG-47554 Change-Id: I4853c5e9b9168d4a417200e2a45a1bf9cb103a30 Reviewed-by: David Faure Reviewed-by: Pierre Rossi Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutex.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 002a9cc7bc..3269ee3ae8 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -563,7 +563,28 @@ const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = { }; typedef QFreeList FreeList; -Q_GLOBAL_STATIC(FreeList, freelist); +// We cannot use Q_GLOBAL_STATIC because it uses QMutex +#if defined(Q_COMPILER_THREADSAFE_STATICS) +FreeList *freelist() +{ + static FreeList list; + return &list; +} +#else +FreeList *freelist() +{ + static QAtomicPointer list; + FreeList *local = list.loadAcquire(); + if (!local) { + local = new FreeList; + if (!list.testAndSetRelease(0, local)) { + delete local; + local = list.loadAcquire(); + } + } + return local; +} +#endif } QMutexPrivate *QMutexPrivate::allocate() -- cgit v1.2.3