diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-11-29 14:06:50 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-03 11:45:18 +0100 |
commit | 9302169bd5ad8380ebe95f50986d2b32eb486901 (patch) | |
tree | bbcbbc8362c493993eba0e526d6e2d6584c1ba3f /src | |
parent | c70750f5363999640cc99278ccf90679fb27c84d (diff) |
QtConcurrent: Workaround GCC bug 58800 in median calculation
1) Revert 880b614 for libstdc++ <= 4.7.3 || (4.8.0 >= ... <= 4.8.2)
2) Fix off-by-one error in reverted code for Median::_bufferSize <= 2.
Task-number: QTBUG-35058
Change-Id: I9d226c2806c1cf06c3d5b9c9f371262d2d69bf2b
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/concurrent/qtconcurrentmedian.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentmedian.h b/src/concurrent/qtconcurrentmedian.h index b39b3ed32b..ce2afb9c28 100644 --- a/src/concurrent/qtconcurrentmedian.h +++ b/src/concurrent/qtconcurrentmedian.h @@ -102,10 +102,19 @@ public: { if (dirty) { dirty = false; + +// This is a workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800 +// Avoid using std::nth_element for stdlibc++ <= 4.7.3 || (>= 4.8.0 && <= 4.8.2) +#if defined(__GLIBCXX__) && (__GLIBCXX__ <= 20130411 || (__GLIBCXX__ >= 20130322 && __GLIBCXX__ <= 20131016)) + QVector<T> sorted = values; + std::sort(sorted.begin(), sorted.end()); + currentMedian = sorted.at(bufferSize / 2); +#else QVector<T> copy = values; typename QVector<T>::iterator begin = copy.begin(), mid = copy.begin() + bufferSize/2, end = copy.end(); std::nth_element(begin, mid, end); currentMedian = *mid; +#endif } return currentMedian; } |