diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2022-05-31 16:49:31 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2022-06-02 15:14:00 +0200 |
| commit | 6376b1c5a708ddb1a82e81cbc7ce4df159ba565b (patch) | |
| tree | 3771a305237d89e7a3f731215f7952af340a5720 /src | |
| parent | a248d8daf5d12795c2891c3ac8978b1f728e43e8 (diff) | |
QBrush: port from array of char[24] to qOffsetStringArray()
QOffsetStringArray has a more compact representation and silences
warnings from GCC 12 builds with asan and ubsan sanitizers enabled:
qbrush.cpp: In function ‘QDebug operator<<(QDebug, const QBrush&)’:
qbrush.cpp:978:77: error: array subscript [0, 31] is outside array bounds of ‘const char [25][24]’ [-Werror=array-bounds]
978 | dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
| ~~~~~~~~~~~~~~~~~~~~~~^
qbrush.cpp:954:23: note: while referencing ‘BRUSH_STYLES’
954 | static const char BRUSH_STYLES[][24] = {
| ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors
Task-number: QTBUG-103923
Pick-to: 6.3 6.2
Change-Id: I5f81f516894e57b47783e2d89489a676b657fdb7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui/painting/qbrush.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index c195dc05539..b0538962332 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -18,6 +18,7 @@ #include <QtCore/qnumeric.h> #include <QtCore/qfile.h> #include <QtCore/qmutex.h> +#include <QtCore/private/qoffsetstringarray_p.h> QT_BEGIN_NAMESPACE @@ -951,7 +952,7 @@ bool QBrush::operator==(const QBrush &b) const */ QDebug operator<<(QDebug dbg, const QBrush &b) { - static const char BRUSH_STYLES[][24] = { + static constexpr auto BRUSH_STYLES = qOffsetStringArray( "NoBrush", "SolidPattern", "Dense1Pattern", @@ -972,7 +973,7 @@ QDebug operator<<(QDebug dbg, const QBrush &b) "ConicalGradientPattern", "", "", "", "", "", "", "TexturePattern" // 24 - }; + ); QDebugStateSaver saver(dbg); dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; |
