From 1fb3d849e426fafcd5af30ce8ee6a00a10891746 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 2 Oct 2012 16:50:01 +0200 Subject: [PATCH] compile fix for MSVC 2008 and std::upper_bound qUpperBound was replaced by std::upper_bound. Unfortunately the STL of MSVC 2008 enforces the definition of the operator in both directions. Change-Id: I3e0f775c23e43332d106e0847d3611e488da6c06 Reviewed-by: Joerg Bornemann Reviewed-by: Konstantin Ritt --- src/gui/text/qtextdocumentlayout.cpp | 20 ++++++++++++++++++++ src/gui/text/qtextengine.cpp | 5 ++++- src/widgets/widgets/qwidgettextcontrol.cpp | 21 +++++++++++---------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 15177dd..9b77c9c 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -401,6 +401,26 @@ Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint, int pos) return checkPoint.positionInFrame < pos; } +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +//The STL implementation of MSVC 2008 requires the definitions + +Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCheckPoint &checkPoint2, const QCheckPoint &checkPoint1) +{ + return checkPoint1.y < checkPoint2.y; +} + +Q_STATIC_GLOBAL_OPERATOR bool operator<(QFixed y, const QCheckPoint &checkPoint) +{ + return y < checkPoint.y; +} + +Q_STATIC_GLOBAL_OPERATOR bool operator<(int pos, const QCheckPoint &checkPoint) +{ + return pos < checkPoint.positionInFrame; +} + +#endif + static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect = QRectF()) { p->save(); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 0c90589..8527a85 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2540,7 +2540,10 @@ namespace { struct QScriptItemComparator { bool operator()(const QScriptItem &a, const QScriptItem &b) { return a.position < b.position; } bool operator()(int p, const QScriptItem &b) { return p < b.position; } - //bool operator()(const QScriptItem &a, int p) { return a.position < p; } +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +//The STL implementation of MSVC 2008 requires the definition + bool operator()(const QScriptItem &a, int p) { return a.position < p; } +#endif }; } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index ec3663e..a2e8230 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1408,14 +1408,15 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const return r; } -static inline bool firstFramePosLessThanCursorPos(QTextFrame *frame, int position) -{ - return frame->firstPosition() < position; -} - -static inline bool cursorPosLessThanLastFramePos(int position, QTextFrame *frame) -{ - return position < frame->lastPosition(); +namespace { +struct QTextFrameComparator { +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +//The STL implementation of MSVC 2008 requires the definition + bool operator()(QTextFrame *frame1, QTextFrame *frame2) { return frame1->firstPosition() < frame2->firstPosition(); } +#endif + bool operator()(QTextFrame *frame, int position) { return frame->firstPosition() < position; } + bool operator()(int position, QTextFrame *frame) { return position < frame->firstPosition(); } +}; } static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor) @@ -1425,9 +1426,9 @@ static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor) const QList children = frame->childFrames(); const QList::ConstIterator firstFrame = std::lower_bound(children.constBegin(), children.constEnd(), - cursor.selectionStart(), firstFramePosLessThanCursorPos); + cursor.selectionStart(), QTextFrameComparator()); const QList::ConstIterator lastFrame = std::upper_bound(children.constBegin(), children.constEnd(), - cursor.selectionEnd(), cursorPosLessThanLastFramePos); + cursor.selectionEnd(), QTextFrameComparator()); for (QList::ConstIterator it = firstFrame; it != lastFrame; ++it) { if ((*it)->frameFormat().position() != QTextFrameFormat::InFlow) r |= frame->document()->documentLayout()->frameBoundingRect(*it); -- 2.7.4