The code basically wants to get the last element of equal_range(id).
The problem is that backwards iteration on QHash is very expensive,
because it's implemented as forward search with wrap-around at bucket
end.
So it was implementing its own equal_range with look-ahead. The
problem is that it compared each key in the equal_range twice: once in
the if, and once more in the following while iteration.
I expect to see this kind of algorithm more as we move away from the
fake bidirectionalism of QHash, so I decided to implement it in a
generic way. We can copy it somewhere else when we find more users.
Change-Id: I7951652107ab897f6a456035f02e0339835e078d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
As in QVarLengthArray (c34242c679), this will
probably bite someone someday, so fix it before there's a bug report.
Use ctor delegation to keep code size increase small.
There's also the benefit that default-constructing a QNetworkRequest now
no longer creates an expensive QUrl object just to destroy it unused again.
Add an auto-test.
Change-Id: I5ceb5402ca3946048d695244d1b1c36564a1e80a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Not visible in QMake, because of too old C++ standard used to compile it,
but in the qttools copy. Fix here, as the authorative source, first.
Change-Id: I2552eccfaab2cef0863686dcd888f2a5f25ca29f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QChar currently is convertible from nearly every integral type. This
is bad code hygiene and should be fixed come Qt 6.
The present patch is the result of compile fixes from marking these
constructors explicit.
Amends 60ca2f5f7c.
Change-Id: I06887104d42f8327eb6196afcde5f942a74a6a78
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The first one is trivially correct: it clearly doesn't modify the
container under iteration.
The second is a bit more subtle, because drawWindow() could be
expected to call a paintEvent and this could theoretically lead to
lowering, closing, or opening of a window. But this function just ends
up blit()ting, so it doesn't call into user code.
Change-Id: Id15e0102e9c8aa12516af27d771104e9993c48a1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
The content is static, so a dynamic container is overkill. Use a C array.
Don't make it static, as that creates more problems than is solves (static
initialization).
Change-Id: I07534c3336efbb6bbc19bfa1b8dad0c578d4e274
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
The qdoublescanprint_p.h header moved from tools/ to text/ when
text/ was introduced.
Amends a9aa206b7b.
Change-Id: Ia7167fc3c4cdb05d4f2e56c0a0427a80e3cee362
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Don't call realloc() with all its machinery when we know exactly what
to do: destroy the last element and decrease the size by one.
Extend the test, removing the unused Foo class for a new Tracker one.
Change-Id: I568eef4f6335669689fb16fd23af92cb4d6464bd
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Clang warns that the private field semaphore_ is unused, and is correct,
of course.
Change-Id: Ic1372cedd3f4b2facca9f6f6be398d26f406b379
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
On the WASM platform, the macro CMDG_NEXTHDR, which is not under our
control, emits a warning about comparing ulong and long with each
other, which -Werror turns into an error:
qnativesocketengine_unix.cpp:1004:24: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~
emsdk/emscripten/1.38.30/system/include/libc/sys/socket.h:286:44: note: expanded from macro 'CMSG_NXTHDR'
__CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix by locally disabling the warning.
Change-Id: Ia2ed4318b2ef679b84ac8544835d1e383568ccac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- Replaced the usages of deprecated APIs by corresponding
alternatives in the library code and documentation.
- Modified the tests to make them build when deprecated APIs disabled:
* Made the the parts of the tests testing the deprecated APIs to
be compiled conditionally, only when the corresponding methods are
enabled.
* If the test-case tests only the deprecated API, but not the
corresponding replacement, added tests for the replacement.
Change-Id: Ic38245015377fc0c8127eb5458c184ffd4b450f1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
There's currently only one user, but another one is coming up, so apply DRY
and centralize the work-around for the MSVC warning C4996 on use of 3-arg STL
algorithms in one place.
The code is prepared to handle other algorithms with ease, should any more
crop up.
Change-Id: Ia881888d6a2b5286c6d8d823bc2b76788efad624
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Declare it shared to Qt and make the move method noexcept.
Change-Id: I25d5d255d300fda109ffa1a08e1849b15e9ff29c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
- First compare the d-pointer before dipping into *d
- Keep a running count as we calculate thisEqualRange, as
std::distance() on QHash::iterator is very expensive.
- Skip the pointless first comparison of the unadvanced
iterator's key() with itself (found by Mårten Nordheim)
Also rename (it, thisEqualRangeEnd) → (thisEqualRangeStart, it),
to keep advancing `it`, which is more natural than advancing
an `end` and later resetting it = end.
Change-Id: I2c27c071b9ee23425a763328402dad9efee4cbd0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
In Qt 5.0, delta() and orientation() were already marked obsolete,
but Widgets and tests have kept on depending on them all this time.
We now start using alternative API so they can really be deprecated.
All constructors except the newest one are also deprecated.
The plan is for all events from pointing devices to have
QPointF position() and globalPosition(), so we deprecate
the other position accessors.
[ChangeLog][QtGui] Obsolete constructors and accessors in QWheelEvent
now have proper deprecation macros. What is left is intended to be
compatible with planned changes in Qt 6.
Change-Id: I26250dc90922b60a6ed20d7f65f38019da3e139e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
QLinkedList is still used in several tests. Add exceptions for
these subdirs.
Change-Id: I50ccd2a0892129d4a47aa4e2400211690da9a82d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
- Unexport the value class, export only out-of-line public member functions
to give us more leeway in changing code later (otherwise, we'd be bound
by BC with MSVC debug builds, which call even inline methods from the DLL.
- Don't use QSharedPointer as the d_ptr. It's twice the size of a pointer.
Use a naked pointer-to-const. Derive Private from QSharedData. This
requires some changes in QColorSpace, and, as usual, an out-of-line copy
ctor.
- Add member-swap(), Q_DECLARE_SHARED().
- Drop noexcept from the dtor. It implicitly is, adding it explicitly looks
weird.
- Pass QRgb and QRgba64 by value, not by cref. They're trivially-copyable,
so passed in registers if passed by value. Passing by cref forces them
onto the stack.
Change-Id: I669643d219ede6b7d07f15afbf8728e16150b3b2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
It is an undocumented and unused method with an obscure name.
Change-Id: Ife27bf836447865cd305c8c7fc9c438759b439cb
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
The mapping is completely static and the key is the index, so just use
a const char array. The only twist here is that to avoid relocations,
we use an array of const char[4] instead of const char*[].
Change-Id: I001b4db833f14e000676125f6f1be4484d996e0b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
The QHash was mapping equivalent values of different enums to each other.
The enums have the same enumerators, though, so if we take care to keep
the two in sync in the future, we can just static_cast them into each
other via int.
Change-Id: Ie67978604f8c3b9477419bc6029bbb869061e938
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There's like three pages of this when compiling the test :)
Change-Id: I923f2c4f5eff7c709977026666cc5b2a2cbfaa72
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The reverts commit 0624c99ea3, which
fixed a GCC 9 -Wdeprecated-copy warning by adding the copy assignment
operator.
The 5.12 change 0e162315 fixed the same warning by removing the copy
ctor. The merge ef37ab99 removed the copy ctor, but kept the
assignment operator added by 0624c99e, bringing the original warning
back, but with the roles of copy ctor and assignment operator
reversed.
One has to give.
Change-Id: Ib32841df94a5ff80402a68b5fe776eb82e94136f
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In a CMake regex, you need two backslashes to escape a character. The
.in file therefore needs four backslashes ...
This amends ba4fdd99ff
Fixes: QTBUG-76698
Change-Id: Ic757354ba596bf020c3ee5e90ee6d2d0fe3ba352
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
- Remove virtual from functions declared as override
- Use " = default" for trivial constructors/destructors
- Remove all special functions from QTestLog
Apply Fixits by Qt Creator with some amendments.
Task-number: QTBUG-69413
Change-Id: I812b8116e5b4c927e4e5cee44e63bc705385d866
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Apply Fixits by Qt Creator with some amendments.
Task-number: QTBUG-69413
Change-Id: I620e40a277dc2b20b0ec26fc32577e66b0456bb3
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Apply Fixits by Qt Creator with some amendments.
Task-number: QTBUG-69413
Change-Id: Iba0834dc89cbfc215acc5873f31fa6eeed74177d
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Change-Id: Ifecb1bac475512241de9bcf195955409bb3adaff
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Modified a regular expression in syncqt.pl so that the special case of
a class beginning with another class does not lead to the exclusion of
the first one. This affects the generation of the install target for
generated class headers of Qt modules. Now the expression verifies the
class names are not identical.
Fixes: QTBUG-71323
Change-Id: I210b4d4c3ed64cf189594b95b10aa0e8495a19d2
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Also fix the name mismatch between the Windows- and non-Windows
versions of loadOpenSsl(), which, presumably, were caused by having
two different return values, something easily fixed by defining a
small struct instead of using a QPair.
Some #ifdef'ery saved, and a lot of brittle deletes on early returns.
Change-Id: I77440de2f6fa51759510506ff4ef51917eb5b3ea
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
When building Qt, qt_build_config.prf adds all directory variables but
DESTDIR to QMAKE_DIR_REPLACE_SANE. We must not add the content of
QMAKE_DIR_REPLACE_SANE unconditionally to QMAKE_DIR_REPLACE in order
to avoid duplicate entries.
Duplicate entries result in an interesting build folder structure like
.obj
├───debug
│ └───debug
└───release
└───release
This commit amends 274882a5.
Change-Id: Ifa8178410d82f58635babc46d43774bab522fbf8
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
A declaration of fromStdVariant() was not visible to qdoc
because it was ifdef'ed out. This update ensures that qdoc
sees the declaration.
Change-Id: I4b00a895aa61175296ec80806b43311eff4f25ca
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
We need localtime_r() in several places. To have this function
declared when including time.h, _POSIX_THREAD_SAFE_FUNCTIONS must be
defined. E.g. qdatetime.cpp includes unistd.h before time.h to define
said macro.
However, this falls apart when precompiled headers are used, because
of the following include chain in qt_pch.h:
qcoreapplication.h -> qobject.h -> chrono -> time.h
This patch ensures that _POSIX_THREAD_SAFE_FUNCTIONS is defined before
including time.h in qt_pch.h by including unistd.h early.
Fixes: QTBUG-76680
Change-Id: I3875072edf37f45492f29d84fc297a9682e11db4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
It's not done by toWCharArray. This caused some issues as we were using
API requiring a null-terminator. wcslen for instance was measuring the
string as being millions of characters long, causing fairly quick
crashes when appending.
Change-Id: Iedaaf9f195be22a610543ab649da92a87cb71973
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Factor out a helper template formatting the QCOMPARE failure message
delaying the formatting of the parameters with toString() and use that
for float, double, int and unsigned. This removes the need to always
format and allocate strings for the operands even in the success case,
speeding up the QColor test from 3.3s to 700ms (Windows/release).
Task-number: QTBUG-38890
Change-Id: I999484765bdaed921d3fc35f35a9fbbcd82a9704
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When accidentally running a test doing screen-grabbing
with High DPI scaling active, sizes of the obtained pixmaps
can differ due to the device pixel ratio. Add a check to make that
clearer.
[ChangeLog][QtTestLib] Comparison of QImage, QPixmap now checks for the
device pixel ratio.
Change-Id: Id8d5187e99c565c44a7bfb8b9cfb09737815fb15
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Use member initialization in private classes and repack members to
minimize padding.
Use delegating constructors and default constructors/destructors.
Task-number: QTBUG-76493
Change-Id: Iaea8880811782ee5846c128590b83c23e6fae445
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The users voted for smaller top margin while there was neither title
nor checkbox.
Task-number: QTBUG-44056
Change-Id: I5bd5cabb094c9cdec379f20e206196f1b5432182
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This reverts commit 17512d497d.
Reason for revert: force vmx instructions to Coin level B virtual
Relates to qt/qt5 84ff024609e4eca003c604294b4102e73deba8c3
Change-Id: Id87a5629a5cd6ebc18c676eae390466e280fc600
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>