diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-12-15 13:30:02 -0300 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-12-16 14:21:56 -0300 |
commit | 5bdf03798de8796eed20e842acfe498a4417af7f (patch) | |
tree | 02575f398d7fb774fc758aa9cc9ef11d4ad887cd /src/plugins/platforms/xcb | |
parent | 8602a224b6ade5680329270d8d573b786a7a81a1 (diff) |
XCB: use qOffsetStringArray
This is the last string array I can see in qtbase sources for libraries
(there are more in tests and qmake, which don't matter much).
Pick-to: 6.4 6.5
Change-Id: I69ecc04064514f939896fffd1731046cebdfe3c9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_basic.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp index 5f1b964afa..6416003bea 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qxcbconnection_basic.h" #include "qxcbbackingstore.h" // for createSystemVShmSegment() +#include "private/qoffsetstringarray_p.h" #include <xcb/randr.h> #include <xcb/shm.h> @@ -27,7 +28,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaXcb, "qt.qpa.xcb") #if QT_CONFIG(xcb_xlib) -static const char * const xcbConnectionErrors[] = { +static constexpr auto xcbConnectionErrors = qOffsetStringArray( "No error", /* Error 0 */ "I/O error", /* XCB_CONN_ERROR */ "Unsupported extension used", /* XCB_CONN_CLOSED_EXT_NOTSUPPORTED */ @@ -36,7 +37,7 @@ static const char * const xcbConnectionErrors[] = { "Failed to parse display string", /* XCB_CONN_CLOSED_PARSE_ERR */ "No such screen on display", /* XCB_CONN_CLOSED_INVALID_SCREEN */ "Error during FD passing" /* XCB_CONN_CLOSED_FDPASSING_FAILED */ -}; +); static int nullErrorHandler(Display *dpy, XErrorEvent *err) { @@ -60,8 +61,7 @@ static int ioErrorHandler(Display *dpy) /* Print a message with a textual description of the error */ int code = xcb_connection_has_error(conn); const char *str = "Unknown error"; - int arrayLength = sizeof(xcbConnectionErrors) / sizeof(xcbConnectionErrors[0]); - if (code >= 0 && code < arrayLength) + if (code >= 0 && code < xcbConnectionErrors.count()) str = xcbConnectionErrors[code]; qWarning("The X11 connection broke: %s (code %d)", str, code); |