qt5base-lts/examples/widgets
Axel Spoerl 585bfe600a Fix pointer mismatch after QList::move() in tooltip example
The tooltip example moves shape items within a QWidget. Shape items are
stored in a QList of objects. When an item is moved, its pointer is
taken from the QList and stored in a member variable. To have the moved
item on the bottom of the list, QList::move() is called. This
operation re-arranges the list objects, and the member variable starts
pointing at a wrong object.

This patch changes the list from a list of objects, to a list of
pointers. Shape items are therefore allocated on the heap.
A destructor is added to free the heap with qDeleteAll.

The example's documentation is adapted accordingly and a snippet for
the destructor is added.

As a drive-by, int is replaced by qsizetype where it was used as an
index of a QList.

Fixes: QTBUG-104781
Pick-to: 6.5 6.2
Change-Id: I9be26fa7954be5f85729d24f166d66980af71801
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-03-28 08:59:53 +00:00
..
animation Examples: Add missing include guards 2023-02-01 18:12:36 +00:00
desktop Fix qtbase build when all deprecated code are disabled 2023-02-22 22:27:35 +08:00
dialogs Move findfiles example into manual tests 2023-02-09 00:23:34 +01:00
doc Fix pointer mismatch after QList::move() in tooltip example 2023-03-28 08:59:53 +00:00
draganddrop Fix qtbase build when all deprecated code are disabled 2023-02-22 22:27:35 +08:00
effects Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
gallery Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
gestures Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
graphicsview Move anchor layout example to manual tests 2023-03-02 17:24:53 +00:00
itemviews Doc: move snippet for implicit translation context 2023-03-01 22:22:26 +01:00
layouts Remove showMaximized() workaround for Android in examples 2022-12-02 15:53:37 +01:00
mainwindows mainwindow example: Fix implicit conversion from qsizetype warnings 2023-03-23 16:39:19 +01:00
painting examples: port widget examples to new connection style 2023-02-25 22:11:57 +01:00
qnx/foreignwindows Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
richtext examples: Connect Quit action to QCoreApplication::quit, not QWidget::close 2023-02-20 15:18:18 +01:00
scroller Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
tools CMake: build the shared plugin when building the plugandpaint target 2023-03-28 10:45:55 +02:00
touch Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
tutorials Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
widgets Fix pointer mismatch after QList::move() in tooltip example 2023-03-28 08:59:53 +00:00
windowcontainer Examples: Use PRIVATE CMake linkage 2022-11-30 14:48:50 +01:00
CMakeLists.txt Examples: Use Qt6:: to qualify Qt CMake packages 2022-11-17 19:59:11 +01:00
widgets.pro Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00