diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-09-02 14:37:54 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-09-04 21:27:43 +0200 |
commit | e192643c2dbc9228b4057661bf58945195836206 (patch) | |
tree | e5c6ac3ccd41e4b624c2e72c772923e84af0976b /src | |
parent | 32a0e0cc616fa9c34ecb6f839b933588f7d4ff3e (diff) |
QCommonStyle: replace a QPolygon with a QPoint[] (II)
No need to allocate dynamic memory for a fixed-size point array
when QPainter has a (QPoint*,int) overload.
Change-Id: Ifdf8224ddffe06ef7848562023e372e2c32b9ad6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 27431a4401..1657879852 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -521,11 +521,6 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (pe == PE_IndicatorSpinUp && fw) --sy; - QPolygon a; - if (pe == PE_IndicatorSpinDown) - a.setPoints(3, 0, 1, sw-1, 1, sh-2, sh-1); - else - a.setPoints(3, 0, sh-1, sw-1, sh-1, sh-2, 1); int bsx = 0; int bsy = 0; if (opt->state & State_Sunken) { @@ -537,7 +532,13 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q p->setPen(opt->palette.buttonText().color()); p->setBrush(opt->palette.buttonText()); p->setRenderHint(QPainter::Qt4CompatiblePainting); - p->drawPolygon(a); + if (pe == PE_IndicatorSpinDown) { + const QPoint points[] = { QPoint(0, 1), QPoint(sw-1, 1), QPoint(sh-2, sh-1) }; + p->drawPolygon(points, sizeof points / sizeof *points); + } else { + const QPoint points[] = { QPoint(0, sh-1), QPoint(sw-1, sh-1), QPoint(sh-2, 1) }; + p->drawPolygon(points, sizeof points / sizeof *points); + } p->restore(); break; } #endif // QT_NO_SPINBOX |