QRawFont: improve the thread-safety checks
384388f2 introduced some checks, and used an assignment in an assert;
that sets off compiler warnings about expressions with side effects
into an assertion. Hence, that code needs to be reworked a bit.
Unfortunately, there's no single define we can use to know if
assertions are enabled or not in Qt, so simply use QT_NO_DEBUG
to enable/disable those checks. The actual "thread" data member
is kept around to avoid break ABI depending on debugging flags.
Change-Id: I8b07e7ff6f81359d6b0653a1d9cc2b720541d1b9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
bb10
parent
c013104b04
commit
ceeb032de6
|
|
@ -70,14 +70,18 @@ public:
|
|||
, hintingPreference(other.hintingPreference)
|
||||
, thread(other.thread)
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread());
|
||||
#endif
|
||||
if (fontEngine != 0)
|
||||
fontEngine->ref.ref();
|
||||
}
|
||||
|
||||
~QRawFontPrivate()
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
Q_ASSERT(ref.load() == 0);
|
||||
#endif
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
|
|
@ -89,27 +93,36 @@ public:
|
|||
|
||||
inline bool isValid() const
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread());
|
||||
#endif
|
||||
return fontEngine != 0;
|
||||
}
|
||||
|
||||
inline void setFontEngine(QFontEngine *engine)
|
||||
{
|
||||
#ifndef QT_NO_DEBUG
|
||||
Q_ASSERT(fontEngine == 0 || thread == QThread::currentThread());
|
||||
#endif
|
||||
if (fontEngine == engine)
|
||||
return;
|
||||
|
||||
if (fontEngine != 0) {
|
||||
if (!fontEngine->ref.deref())
|
||||
delete fontEngine;
|
||||
#ifndef QT_NO_DEBUG
|
||||
thread = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
fontEngine = engine;
|
||||
|
||||
if (fontEngine != 0) {
|
||||
fontEngine->ref.ref();
|
||||
Q_ASSERT(thread = QThread::currentThread()); // set only if assertions enabled
|
||||
#ifndef QT_NO_DEBUG
|
||||
thread = QThread::currentThread();
|
||||
Q_ASSERT(thread);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue