Tidies up the test output by removing expected warnings from the log
(and alerting us if they're missing).
Amends 64f6169f61ce8c982a1b92b20f930518a5f0d477, which introduced the
warning.
Pick-to: 6.8 6.5 5.15
Change-Id: Idcef99d556b11035307e6e207cf31fc2f13ed291
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit e55479ea4a2dca266b73a2a17ff77ec44e1c2135)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The minimumContentsLength() is user-settable, and tst_QComboBox
actually sets it to INT_MAX as some point. As such, the implementation
needs to defend itself from UB, either by limiting what values it
accepts as minimumContentsLength() or by making sure it doesn't cause
signed overflow in calculations involving this user-controlled
variable.
The former doesn't really work as long as the test checks that INT_MAX
is accepted as-is, so we need to do the latter.
Do the calculation in qint64, and use the result only when it doesn't
exceeed good old QWIDGETSIZE_MAX.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I8aac7bda593095638c9c09db3b70b4c84e698419
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 00fdf9e432c78e7d7f1a491f7bc1f375fcbde8da)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QProxyStyle's ctor arguments are not QObject parents, but the proxied
style, which becomes the proxy's QObject ... get this ... _child_.
What a broken concept... It means that this test function took
ownership of QApplication::style(), and the only way it wasn't going
to wreak havoc on the rest of the test functions was to leak it after
use.
To fix, create the style on the stack, so it gets automatically freed
by the compiler on all exists from the function. As a drive-by, use {}
instead of () to call the ctor (not to prevent C++' Most Vexing Parse,
just because it's easier on the eye).
The meat of the change, however, is in making the helper proxy-style
defend against QProxyStyle's grabbing of the baseStyle() as its child,
and managing baseStyle()->d->proxyStyle so we properly dissociate from
qApp->style() after we're done. Needed to use ctor delegation to
extract original parent and proxy model from the incoming style before
QProxyStyle, our first subobject, gets first picking on the style,
destroying the very state we're trying to preserve.
This should be become some QTest::LocalProxyStyle, if we find more
users of this pattern.
Amends 5cff7d2b679d48a247b4630cb9e3d5b04fab0b55.
Pick-to: 6.8 6.5 5.15
Change-Id: I2abf4a0bf54158254fd8d526de55ad486ca4e296
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit d88459139119b898e81c1a104e6fd3e28c8f01cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Both the QCompleter and the QSortFilterProxy objects are not owned by
the QComboBox merely by setting them as completer and model. Having no
other QObject parents, and having being allocated on the heap, they
were leaked.
To fix, give them the combo-box as QObject parent.
Amends 8b6d6d4832ea8ed5f9857d5ddf06408ee9d0b4e0.
Pick-to: 6.8 6.5 5.15
Change-Id: I5c3594272a5283a3fbaeb9885d315047b04f30de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 27279e01d2794bba8c69db4b987c3351a2daa619)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
A QComboBox does not own the model set on it, because models can be in
many views at once. So the QStringListModel, allocated on the heap
without a QObject parent was leaked.
Fix by giving the model the combo-box as QObject parent.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Idd9057c8f796937d9d3c5c4ef99b329124d2192d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit c41592c900257177849758ef31212a83fc813be5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QItemDelegates are owned by neither the QComboBox directly, nor the
QComboBox::view(), upon a mere setItemDelegate() (the docs of this
function is pretty clear about that). Since the objects didn't have a
QObject parent, either, they were leaked.
To fix, give it the comboBox as a parent.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Ic8bc2603072070b458bd79a6129af6c76811f8ec
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit fda3526f9c6c34f509ebaba67a27e5c32235d7e9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Contrary to what the code comment suggested, a QComboBox does not own
the object passed in by setItemDelegate(). After a nullptr check, the
function merely forwards to QComboBox::view()->setItemDelegate() and
QAbstractItemView::setItemDelegate() documents very clearly that the
item delegate ownership does not change. Consequently, the test
function leaked the object.
To fix, hold it in a unique_ptr and reset() at the end of the code
block.
I opted to not merely comment in the delete there, because that would
still leak in case one of the QCOMPARE()s in-between failed. While it
is not the purpose of the current work to make tests leak-free even on
failure, it likewise makes little sense to not reap this small benefit
now, albeit at the cost of a bit of git history mess-up, itself
mediated by the fact that we're picking this all the way back, since
this...
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I1e604b795f5a12dc8829bf5913b88bc7c7110352
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 0de7cafabc6d71cf3c129e7a67792d2a3ff1c864)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QLineEdit remembers whether a QWidget size-widget came from a
QWidgetAction or is just one of its own QLineEditIconButtons. On
removal of the action, if QWidgetAction, it will ask the action to
deal with its widget, calling QWidgetAction::releaseWidget(),
otherwise it just deletes the QLineEditIconButton itself.
This is fine if the action is being removed from the line edit, but
not immediately deleted. But if the action is being deleted while its
widget is still in a QLineEdit, then the QLineEdit is informed of this
only by ~QAction(), at which point the QWidgetAction has ceased to
exist and the cast, in QLineEditPrivate::removeAction(), to
QWidgetAction is UB.
Says UBSan:
qlineedit_p.cpp:656:10: runtime error: downcast of address 0x6020000c3950 which does not point to an object of type 'QWidgetAction'
0x6020000c3950: note: object is of type 'QAction'
00 00 00 00 70 57 49 81 3d 7f 00 00 80 bc 0c 00 50 61 00 00 03 02 00 00 10 00 00 00 a6 01 00 71
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QAction'
#0 0x7f3d93910686 in QLineEditPrivate::removeAction(QAction*) qlineedit_p.cpp:656
#1 0x7f3d938b44bc in QLineEdit::event(QEvent*) qlineedit.cpp:1469
#2 0x7f3d91c50211 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
#3 0x7f3d91cd160a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
#4 0x7f3d697f6ada in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
#5 0x7f3d697f94e3 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
#6 0x7f3d92345199 in QWidget::removeAction(QAction*) qwidget.cpp:3215
#7 0x7f3d92e47202 in QtWidgetsActionPrivate::destroy() qaction_widgets.cpp:35
#8 0x7f3d7f75d5fb in QAction::~QAction() qaction.cpp:451
#9 0x7f3d92e4cc76 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
#10 0x7f3d92e4e965 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
#11 0x558c993da3b0 in tst_QLineEdit::sideWidgets() tst_qlineedit.cpp:4693
To fix, check the dynamic type of the action (using qobject_cast)
before calling QWidgetAction::releaseWidget(). If the cast fails, the
QWidgetAction will have dealt with the widget itself, in its own dtor,
so QLineEdit needn't do anything.
Unfortunately, fixing this centrally by just dragging destroy() down
from ~QAction() to ~QWidgetAction() causes use-after-free in other
test functions of tst_QLineEdit, so I deciced to fix this at the
QLineEdit level only.
Amends 9ce12cc8de940cdd450a28f4bd079acfc3621aa3.
Pick-to: 6.8 6.5 5.15
Change-Id: I3c514dbd1f1a4e1510df3dd9ac67b4bab50e63e9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit bf62a9762b04689094d1411168ad785b2152cba4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The test uses the old-but-invalid trick of inheriting from a class X
to gain access to its private or protected parts, but then just
casting an object of dynamic type X to the newly derived class. This
is invalid, because the object is not actually of the newly-derived
type.
Says UBSan (excerpt):
tst_qtextedit.cpp:2273:5: runtime error: downcast of address 0x60400013c190 which does not point to an object of type 'PublicTextEdit'
0x60400013c190: note: object is of type 'QTextEdit'
00 00 00 00 70 bc 57 df b1 7f 00 00 80 66 30 00 90 61 00 00 70 be 57 df b1 7f 00 00 00 00 be be
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QTextEdit'
To fix, make QTextEdit befriend tst_QTextEdit. This is how we do it
elsewhere, too. Then remove the now-unused PublicTextEdit helper.
Amends the start of the public history, and, in one function,
56f0ebfe860e440dcbba8997f44836debc901119 (which is only in Qt 6.4+, so
the cherry-pick to 5.15 will have to drop the part in pasteFromMarkdown().
Pick-to: 6.8 6.5 5.15
Change-Id: I967238d84cae0f6dd8f05d0afb7a318292d96415
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 73fc32af1410b54fc38d7450fad04bb9dabec077)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The constructor new'ed up a MyPaintEngine, but there was no destructor
to delete the object again. Neither is ownership of the engine
transferred out of the class, so the object was leaked.
Fix by holding it in a unique_ptr.
Amends 391e3aeef45efc937979b44c32147206e389a60b.
Pick-to: 6.8 6.5 5.15
Change-Id: I0c4da10d5a1659eceac0deba32cac757579e46c5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit de2de7e12cb82064e32197f88c8772ceeeead8ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QMetaType::Void is not constructible, so create() will return nullptr,
and even though sizeOf() returns 0, calling memcmp() is still UB in
that case.
Fix by guarding the memcmp() from QMetaType::Void.
Amends a59e7361714d50687d82a2d9abae9e95825a23b6.
Pick-to: 6.8 6.5
Change-Id: I55896826e6c0cad5d77e9d0ab861efa9a32f780f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c6c2a0bf3799c9851551bc9e1bd0919dbc64924c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
To benefit from -Wswitch compiler flag, requested by Marc in code
review.
Define supportsAlgorithm() twice, with/without USING_OPENSSL, amends
9248d0cfbee0805d670f4b6b07bd3bf4003d6263.
Change-Id: I236093532196689bc0828131360dfeeb24fac23f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 095e6fd0840ad4cd578a022ec361ebf716dfa843)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Rename the parameter 'code' to 'nativeErrorCode' to match the getter
nativeErrorCode() with the ctor's parameters.
Pick-to: 6.8
Change-Id: Ic95b45c75a57796536d845249c719b5d0d0e7587
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 06ef995a7d348c9769091b07e4511c3c9511a104)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
We store timestamps as utc in the database but QSqlDriver::formatValue()
does not format the datetime string as utc. Fix it by converting the
datetime object to utc first.
This amends 2781c3b6248fe4410a7afffd41bad72d8567fc95
Pick-to: 6.8
Fixes: QTBUG-135135
Change-Id: Id26b251e9ed9800d6caff7f43de25fd9e9b08f43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 219e9fe7a2312538635aaf1c0bc79b98df21723e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
After c5792dcfd631abb4f9e2b92cd6e88d7e5c373406 the last cursor position
is reflected as a QPoint(std::numeric_limits<int>::max(), ...), and
after 209a2145f94e99f99832c3a08cdf579d8f42ca55 as 1 << 23. Instead of
hard coding the sentinel value, let's use QLastCursorPosition directly.
Pick-to: 6.8 6.5
Change-Id: I24031f3cc800d2f0028eb95f4f8597019cc945c0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 4ae41c225be57492d5bf0e50c58bf18091414c47)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The windows11 style, in contrast to the windows vista style, draws the
indicator on the side. Therefore call QWindowsStyle::sizeHint() for
CT_HeaderSection as the base style has the correct implementation.
Pick-to: 6.8
Fixes: QTBUG-135338
Change-Id: If84f72f9f26e87617ecebb1a01f448219d8656ba
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit 75c896f9b104831e40dfa6ca9aedebaa272704b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Don't confuse the next person working on this code.
Pick-to: 6.8
Change-Id: I3f9ff59299a4150a96cc11d851d06539a5701a70
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 04fbdd25522f3a7a4b53cb553b1ac70e3f8af5e8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The WatchDog thread calls printTestRunTime() which reads the two
timers, created and started in the main thread.
Pick-to: 6.8 6.5
Change-Id: I1a337648fddf87190075b7902311544d0ab21ac3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 9e32306daea5578ac5cff1424678da25e2a158af)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Yield a configuration error with -no-feature-desktopservices
if the platform is either Apple or Android. This should be clearer
than a compiler error later on, and also occurs earlier in the
process.
Pick-to: 6.8
Fixes: QTBUG-135152
Change-Id: I5dfb9eda12472ed9359767f17423fda63d208d9c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit b145f23770a2f88fc54eaaa33eef579c308f4663)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Missed feature guards from:
- QXmlStreamReaderPrivate class declaration
- QXmlStreamWriter::writeCurrentToken definition [*]
[*] Function takes in a qxmlstreamreader. The declaration
of the function already had the necessary feature guard.
Pick-to: 6.8
Fixes: QTBUG-135230
Change-Id: I78741bc75a6baa8bc86ec5ce7d34a4333d8bdad4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 90c90d50715b7e7501b0a2153122d576656b9e4d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
In the FontConfig font database, when we registered alternative
names for the same font, we would just copy the existing user
data (the FontFile struct) from the original font.
However, this did not account for the fact that registerFont()
may in some cases delete fonts from the database if they are
being overwritten, which will also delete the user data.
Therefore the existing FontFile struct is not guaranteed to
be valid once the font database has taken ownership.
This was pre-existing, but it started happening on some
systems after 1d6f71779f05df1af3daacd48f309cd92523152a because
this change will cause some fonts to be seen as identical
which were not before.
Pick-to: 6.8
Fixes: QTBUG-135264
Change-Id: I913bf13dc8069d952a4cdc5fa5544594be1cdba1
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 11620f97f6fb067aa0dce2ee0b1f8ca738c66695)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Amends c7691842f743f568a073582c8f0cacd6ee188f98, and actually fixes the
other half of QTBUG-130142.
Fix the unittest, it was wrong to begin with, iterating over an empty
string with NoDotAndDotDot, next() will always return an empty string
because `currentFileInfo` has never been initialized.
Pick-to: 6.8
Fixes: QTBUG-135287
Task-number: QTBUG-130142
Change-Id: I9966428c7a143803e6e934b5970ea6b6afc8a08f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4fd7d31e0966d52af4dc40c7e47576d40d8b00ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
As far as I can tell, QUuid is working correctly on big endian
platforms. But it stores the integers in such a weird fashion (I wish to
fix that for Qt 7) that this test is non-obvious.
I don't have a big-endian machine to test this with. Anyone interested
is welcome to submit patches.
Fixes: QTBUG-134634
Pick-to: 6.8
Change-Id: I2415be976d1d880d1525fffdf525dcf4f21aaa70
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit aa872148645351a346d34db60cd0b8b1235fed1c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Move the cleanup of the temporary tables into an own function and call them during init and cleanup. this makes sure the tables are
- deleted on clean exit
- not there during init when cleanup was not run (e.g. due to debugging or a crash).
Pick-to: 6.8
Change-Id: I9013a26b0166d0756a37f0a5d50ed825adf63868
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c833ed5711b40465a77a2d43b79e041092e638cc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This fixes a bug when addData() is used to add a full Latin1-encoded
XML document with a proper "encoding" attribute.
Once addData() is called, it immediately converts the data to UTF-8.
However, if the encoding is not locked, the parser will later see
the "encoding" attribute, and try to interpret the data according
to the specified encoding.
The QXSR(QASV) constructor is not affected, because it already locks
the encoding.
Add a unit-test for the issue.
Amends 6bc227a06a0d1392d220aa79ddb1cdc145d4f76e.
[ChangeLog][QtCore][QXmlStreamReader] Fixed a bug when calling
addData() with a Latin1-encoded string containing a full XML document
with an encoding attribute, could result in incorrect parsing of this
document.
Fixes: QTBUG-135033
Pick-to: 6.8 6.5
Change-Id: I9a35d16d743050ea4feccab3d1336747ce0abff4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 4b8659ebf689b79ac88f5935ad662a604f0c8bea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
If debug symbols are needed, then pass the respective flag to the
configure script.
Pick-to: 6.8
Change-Id: I99db92bdd5b7eb896e0d592117a8f218467a4bd7
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 355e0d85eb4a05acd4d5c9d6b2f1cfce7ccdb144)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Implement ensurePositionTopLeft() to set a window's position
to the available top-left corner and verify that it is correctly
positioned.
Incorrect updates to window.position and window.framePosition have
been identified as one of the main sources of flakiness on
Opensuse. This test function addresses this issue and improves test
reliablity.
Task-number: QTQAINFRA-7050
Change-Id: I946f74c7d2c1db9cfe4fec7db272e12876b3ed43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 7929852c1d39e12b7c586b5c6d257c9df27c01df)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The QGraphicsWidget `parent` didn't have a parent itself, and the test
function neglected to delete the object manually, leaking it.
To fix, allocate it on the stack.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Ie9814655c1a52b6dc0d15076eca591fe710d51ae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 76e76afb83b87664aeeaf61b400e4259ce80f49a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The QGraphicsScene object wasn't used, so can be removed.
Make it so.
Seems to amend the start of the public history (and if there was a
user that has since been removed, we'll get a compile error, so no
need to data-mine the git history further).
Pick-to: 6.8 6.5 5.15
Change-Id: I9eeacde057ee5681ea86c185b66dff618a6f364e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 235fe36de7d8789cf6f5a393df01337a59874901)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The QGraphicsWidget didn't have a parent, and wasn't deleted by the
test function, so it leaked.
To fix, hold it in unique_ptr. While we're at it, and so that it
doesn't look too out of place, also hold the other parent-less
QGraphicsWidget in a unique_ptr.
The action, OTOH, has a parent, so we don't need to change something
there.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I0597b7ecd293ac54981df9e276c38c385ac811c7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 92c1413c087c5435858f10c0e0c878bc25211b8f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The result of QStyleFactory::create() is owned by the caller, and this
test function neglected to delete it, leaking the object.
To fix, reset() it, once created, into a unique_ptr. This is the
minimally0-invasive fix.
Amends 9bc49b0bca361646aac90cd00706588d3dcd66c9.
Pick-to: 6.8 6.5 5.15
Change-Id: I17fae174b93bd27e2cac6e5e2d2c8a4ac2de703e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit f0a9b5b6f11dc5deaabadce0ee672530683cf0a0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
`fstyle` is already a QStyle*, so casting it to QStyle* is unneeded.
Amends 9bc49b0bca361646aac90cd00706588d3dcd66c9.
And 0 is a valid nullptr value, so we don't need to cast there,
either.
Amends the start of the public history.
Drive-by port to nullptr.
Pick-to: 6.8 6.5 5.15
Change-Id: If763b8bf42de9d8bbe988ac76773d02bb7a2b68b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit dbfcd541552b51f831521c77fd44e753a97f04db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
If a QGraphicsItem is removed from a QGraphicsScene, it also gets
un-parent-ed, and the caller of removeItem() is responsible for
deleting the item henceforth. The test function neglected that,
leaking the object.
To fix, use a scope-guard to defer deletion of the object to the exit
from the test function. This is the minimally-invasive fix.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Ie4f9be232674bba583f4a59908e42de096930136
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 156bd559231f06136bc368236675688b3c93d02a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The result of QTest::createTouchDevice() needs to be deleted by the
caller. The test function didn't, so leaked the object.
Fix by holding it in unique_ptr.
Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, even though the code
that this patch replaced looked leaky, too.
Pick-to: 6.8 6.5 5.15
Change-Id: I3c7dfab31dc6ab364195381352d98fbd9c730990
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit bfd852c5025e342af3960516df2f871aa08f5982)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The result of QTest::createTouchDevice() needs to be deleted by the
caller. The test function didn't, so leaked the object.
Fix by holding it in unique_ptr.
Amends 1ecf2212fae176b78c9951a37df9e33eb24d4f2d.
Not picking to 5.15, because the cherry-pick of
1ecf2212fae176b78c9951a37df9e33eb24d4f2d to 5.15 was abandoned.
Pick-to: 6.8 6.5
Change-Id: I649357466a51e02d669b114bdfa0746bfa09fe34
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 01ee8fd7b5c93cffaeb8624ed87f5dee36e9e5e6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Like in other test functions in this class, the QGraphicsWidgets were
leaked. So the solution is the same: hold them in a QVLA.
Also like in other test functions, the child layouts _are_ owned by
the parent layout, so were not leaked.
There's a twist here, though: we're removing layout items, which may
be widgets _or_ layouts. The old code deleted the removed layout item,
but we can't do that anymore, since it may be one of the widgets that
are owned by the QVLA, and that would cause a double-delete. If we
don't delete the removed item at all anymore, though, we'd leak it
when it was a layout.
So hold the layouts in QVLA, too. _Then_ we don't need to delete the
removed item anymore.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I16c61eb18f2843ceb72a432db1bd9be29e258bfd
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 0665ae81fb33dc6f71f494ad6df92f85aad70ca4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
After the QGraphicsWidgets have been dealt with in a previous commit,
the last leak in the function is that of 'item'.
Fix by holding it in a unique_ptr.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I56986139a2b7865cf367bdd25ccde90d5e1c50ca
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 59b18d07e78be0b57c8bb7c9078e89c686ddf0f3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This test function hasn't tested anything since the start of the
public history, and leaks memory (the QGraphicsWidgets).
The dump() function, while implemented, doesn't do anything by default
(#ifdef'ed out), so there's no point in adding actual dump() calls
here, either.
Remove this function as dead code.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I6d9d224945fab0f97db0c5ea7d13a7df6c8837b2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 891473270869a29a6efb09962cf4cb19cc4d8d9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The tests added parent-less QGraphicsWidgets to a
QGraphicsLinearLayout, which doesn't reparent them (and cannot,
because it doesn't have an item as a parent itself onto which to
reparent them), so the test functions leaked them.
The layout items, OTOH, do get reparented, and are therefore deleted
by the stack-allocated layout as its children.
Since there's thus no object that could naturally be a parent for the
widget items, allocate them on the stack. Since their number is
variable, use QVLA, whose constructor is able to create a ... wait for
it ... VLA of non-copyable-non-movable elements on the stack (we test
for this, also in Qt 5, see e7c792ba7179c4c81fb2e26f66031ec81234b0d7).
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: I9b0b65efbccd1fd7e708da4d12f746d942f602fe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 374b9fd03145acac49a96abe81a253e9b482230a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The old code used a data-driven test to check that itemAt(i), 0 ≤ i ≤
2, was returning non-nullptr. It re-created the widgets and the layout
for each data tag anew, leaking the widgets by the way.
Using data-driven test machinery here is overkill. Remove it and
create the widgets in a C array on the stack, so they're not leaked,
and iterate over them using range-for.
Also check not just for nullptr, but also that the pointer matches the
widgets we put into layout, at the position we put them in.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Ib808aa6756c6550a61a4768edfc5021f2f6ae3b3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 159029b58753ad8a76eef9ea105275001a430ef2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QStyle objects aren't owned by widgets (or QGraphicsWidgets) they are
set on, so need to be deleted manually. The test function didn't do
that, so they style objects were leaked.
To fix, hold them in unique_ptrs. QStyle subclasses, even though being
QObjects, don't have the usual QObject *parent=nullptr constructor
parameter, so passing a QObject parent isn't an alternative, really.
Amends 66b7e7497c3b318dddeb91175d8f85f606c99eec.
Pick-to: 6.8 6.5 5.15
Change-Id: I6c43264760f7126610fe51f72e74ec341bd2e3d7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit dd9a94a3b32327b4e0f2aaca55cd987a71dd2878)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The test function leaked all the items it created.
Unless I renamed the object and kept the pointers to them by their old
names, any fix would touch every line, anyway. The former would be
pretty contrived in such a short function, so port the complete test
to stack-allocated objects, which is how this function would have been
written today.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Ia8a67825d3a80be4574b7779c2105d53003b9e69
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 64060cbeae86b2bfeccc6fc18df56cd1e829b0e7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
QGraphicsView, being a QWidget, needs to have a parent or be manually
deleted. The test function did neither, so leaked the view.
Fix by allocating it on the stack.
Amends 913ff732004c2c61c39bcdd82ff05ea1827f328b.
Pick-to: 6.8 6.5 5.15
Change-Id: If012d4b833849285b62e2a4b4089457c2aef1d88
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 9bab38b1330a4106e920b66538e4e14b795d33e2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
I honestly didn't bother to figure out the ownership relationships
between these items; the QGraphicsView docs don't help much:
> The layout takes ownership of the items. In some cases when the
> layout item also inherits from QGraphicsItem (such as
> QGraphicsWidget) there will be a ambiguity in ownership because the
> layout item belongs to two ownership hierarchies
but asan said that the AnimatedLayoutItem objects were leaked, so hold
them in unique_ptrs now.
Amends the start of the public history.
Pick-to: 6.8 6.5 5.15
Change-Id: Icd0eabc4129b57251bbec7f8e3752f99ee584cf3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit f3a02fe39d8d0bfea8fa0f087bb95c6e65d77b45)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Several test functions use a centrally-allocated QSplitter for their
tests. This object was allocated in initTestCase(), but
cleanTestCase(), while present, was empty, so nothing deleted the
object again.
Fix by deleting the object in cleanupTestCase(). Initialize the member
variable to nullptr so that the delete is well-formed even if
initTestCase() for some reason didn't run (or didn't run to
completion).
Amends the start of the public history, where this function read
#if defined(QT3_SUPPORT)
delete qApp->mainWidget();
#endif
which was already leaking if QT3_SUPPORT wasn't defined.
Pick-to: 6.8 6.5 5.15
Change-Id: I43e5d8921a9c097f252e11709f25bc622fc8fe15
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit fbaa37633580dcf6b8ec3cd4a0da8d85902de2ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Depending on whether QSplitter::replaceWidget() succeeds or not, we
need to delete either the return value (an unparented QWidget) or the
argument (another QWidget without parent). The test function only
deleted the return value.
Use a unique_ptr for delayed automatic deletion at the end of the test
function, which is the minimally-invasive fix. Use it for both
candidates, which ensures that either one of them is reliably deleted,
even if a QCOMPARE() fails in-between.
One check before we reset(newWidget) is special: if (!res) fails, then
the reaper contained something we also need to delete, and the reset()
will do that, but code checkers (e.g. Coverity) are known to complain
about using a pointer value after a delete, so split the check into
the check and the QVERIFY().
Amends 2c634a132696376a0a0d7641bf05ae875c50190e.
Pick-to: 6.8 6.5 5.15
Change-Id: I8571477d9e53b85b2db041d7c9bdf2bd7aa69906
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 4513d48490f39c805644ea01a5a8e9a16d51764b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The documentation now explicitly explains that the XML declaration is
not a processing instruction according to the XML 1.0 Specification and
the W3C DOM Level 1/2 Core specifications. It advises against using
createProcessingInstruction() to insert an XML declaration and
recommends QXmlStreamWriter.
This clarification aims to reduce confusion caused by the similar syntax
of processing instructions and the XML declaration.
Fixes: QTBUG-21166
Pick-to: 6.8 6.5
Change-Id: I630e0e73bc8e4b6f145cb1e771a0a6fec54543cf
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit d2258328e39ab8695e8034fe85cec7a18884f6d2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>