GCC, with ubsan and optimization enabled, issues -Warray-bounds for the cast from &polygonItem to QGraphicsTextItem*, because the latter is-a QObject and the former is not, so the cast has to adjust the pointer value to correct for the fact that QGraphicsItem is not the first base class of QGraphicsTextItem: qgraphicsitem.h:973:56: warning: array subscript -1 is outside array bounds of ‘QGraphicsPolygonItem [1]’ [-Warray-bounds] 973 | || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr; | ^~~~~~~~~~~~~~~~~~~~ tst_qgraphicsitem.cpp:3193:26: note: while referencing ‘polygonItem’ Check the implementation is correct in this respect by not just checking for nullptr or non-nullptr, but checking that the result matches what dynamic_cast produces. We can assume dynamic_cast works on QGraphicsItems because QPA is using dynamic_cast, so both QtGui and QtWidgets need to have been compiled with RTTI enabled. This doesn't eliminate the GCC warning, but confirms that it is a False Positive. Pick-to: 6.9 6.8 6.5 Change-Id: Ifc262cb6e715e8e68c180855adc2467960da89a1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This directory contains autotests and benchmarks based on Qt Test. In order to run the autotests reliably, you need to configure a desktop to match the test environment that these tests are written for. Linux X11: * The user must be logged in to an active desktop; you can't run the autotests without a valid DISPLAY that allows X11 connections. * The tests are run against a KDE3 or KDE4 desktop. * Window manager uses "click to focus", and not "focus follows mouse". Many tests move the mouse cursor around and expect this to not affect focus and activation. * Disable "click to activate", i.e., when a window is opened, the window manager should automatically activate it (give it input focus) and not wait for the user to click the window.