diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-05-28 15:51:31 -0400 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-06-02 12:03:36 +0200 |
commit | 954c61ff584537d27e1d5974b2b9f488971ae52f (patch) | |
tree | 5d743e456432b1eee4303d9696c49372f6b0bd1a /src/plugins/cpptools/stringtable.cpp | |
parent | 1385844d138e6f7595f0157e2bb36b851c0423f4 (diff) | |
download | qt-creator-954c61ff584537d27e1d5974b2b9f488971ae52f.tar.gz |
CppTools: Fix compilation with Qt4
Change-Id: I76c6ea3557c46fbca4ccb0fb293c6ed6f03e96df
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/stringtable.cpp')
-rw-r--r-- | src/plugins/cpptools/stringtable.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/cpptools/stringtable.cpp b/src/plugins/cpptools/stringtable.cpp index 6d284536ee..9617430d4a 100644 --- a/src/plugins/cpptools/stringtable.cpp +++ b/src/plugins/cpptools/stringtable.cpp @@ -63,7 +63,7 @@ QString StringTable::insert(const QString &string) QMutexLocker locker(&m_lock); QString result = *m_strings.insert(string); - m_stopGCRequested.storeRelease(false); + m_stopGCRequested.fetchAndStoreRelease(false); return result; } @@ -83,15 +83,24 @@ enum { DebugStringTable = 0 }; +static inline int qstringRefCount(const QString &string) +{ +#if QT_VERSION >= 0x050000 + return const_cast<QString&>(string).data_ptr()->ref.atomic.load(); +#else + return const_cast<QString&>(string).data_ptr()->ref; +#endif +} + void StringTable::GC() { QMutexLocker locker(&m_lock); int initialSize = 0; - int startTime = 0; + QTime startTime; if (DebugStringTable) { initialSize = m_strings.size(); - startTime = QTime::currentTime().msecsSinceStartOfDay(); + startTime = QTime::currentTime(); } // Collect all QStrings which have refcount 1. (One reference in m_strings and nowhere else.) @@ -99,18 +108,16 @@ void StringTable::GC() if (m_stopGCRequested.testAndSetRelease(true, false)) return; - const int refCount = const_cast<QString&>(*i).data_ptr()->ref.atomic.load(); - if (refCount == 1) + if (qstringRefCount(*i) == 1) i = m_strings.erase(i); else ++i; } if (DebugStringTable) { - const int endTime = QTime::currentTime().msecsSinceStartOfDay(); const int currentSize = m_strings.size(); qDebug() << "StringTable::GC removed" << initialSize - currentSize - << "strings in" << endTime - startTime + << "strings in" << startTime.msecsTo(QTime::currentTime()) << "ms, size is now" << currentSize; } } |