There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: I3c4647a569b72cd3a628c9b92ef34c87fd588342
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
... instead of qPrintable(), %s, and explicit qt_error_string().
Saves 2KiB in text size on optimized Linux AMD64 GCC 9.1 builds.
Change-Id: I98b6717da1ed1b678f01167d704a96f10da47966
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
... instead of qPrintable() and %s. Avoids temporary QByteArrays.
Saves 1.2KiB in text size on optimized Linux AMD64 GCC 9.1
builds.
Change-Id: Ie626fc478667007ce9a6bc920b8d4ec0451f2cd0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The first two changes avoid creation of a temporary QString and QByteArray each,
by realisiing that QChar is more-or-less wchar_t on Windows and so we can just
use %ls to print the wchar_t array directly.
In msgFindNextFailed(), remove the inline keyword and mark the function as cold
(not sure this has any effect on Windows). When building the result, don't use
QTextStream. Everything that is streamed is text, so just use QString::op+=.
When using the result, use qUtf16Printable and %ls instead of qPrintable and %s,
to avoid the creation of a temporary QByteArray.
Change-Id: I09f576b894761fe342109b386c1de3532200e03c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This allows the QFile factory there to actually return the payload in
a unique_ptr instead of falling back to a raw pointer.
The use of a unique_ptr member requires that the destructor be
out-of-line, since QFile is only forward-declared in the header
file. This is good hygiene, so do it for ProgressDialog, too.
Change-Id: Idb6ed327f9592526bb7d0d5b2cfbffe9f08f3eea
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Collapse the two qWarnings() into one by just storing what is different between them.
Saves more than 400b in text size on optimized AMD64 Linux GCC 9.1 builds.
Change-Id: I16489d6165a550a9ad4ce6a77ca736a1d17a8c8a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There are no QLatin1String overloads, so using QLatin1String as the
format string produced a temporary QString. Use QStringViewLiteral
instead.
Change-Id: I682eb8cfaa98fdcfb491edd290460db636a98a9f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Pack four qWarning() calls into a separate cold function.
Use qUtf16Printable().
Saves >600b in text size on optimized AMD64 Linux GCC 9.1 builds.
Change-Id: Ib25ea473d1d77faaecaf8750726c83675d87279e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: I05a486c2a86fcc7015a9c21ed0ce9682b0c24034
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Scope a previous iterator variable better so we can re-use 'it' as the
iterator name.
Change-Id: I46d239ad2d3646168408d1ef29ed74fd07bc663f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
When the families member was added to QFontDef, it was included
in op== and qHash(), however the seed was passed to two qHash()
calls for subobjects. With xor used as the combiner, it could
happen that the seed was xored out (e.g. on empty strings),
leaving a slight opening for prediciable hash values.
Fix by using QtPrivate::QHashCombine, which handles the seed in
such a way as to avoid the issue.
Change-Id: I8a3e4c2f368306446554249763695158df5ac634
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
There's talk that QScopedPointer may be deprecated. Don't use it
in examples anymore.
Change-Id: Ia50ef66de84dae2885f71a9dd83c5909bfa253f0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This user of QList depended on the stability-of-reference guarantee of QList.
Make that explicit by using a vector of unique_ptrs. Adapt to new API.
This patch does not intend to fix any pre-existing problems with the code,
such as double-lookups. It is focused on getting rid of this questionable
use of QList, so the code doesn't explode when QList temporarily becomes
QVector in wip/qt6. Not more, not less.
Change-Id: I33847f33aa9f411ad9cd6c046653b7ab22a733cb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The function is const, but the d-pointer doesn't propagate it (raw pointer),
so we need the qAsConst() even here.
Change-Id: I9d2e1f7715abb3dc67a87cdadaa7ded971b15848
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The old code iterated over the peer list, inserting active peers into
a QSet, curiously not stopping to search for clients if it had already
determined the peer to be active.
It then iterated over the peers again, storing the indexes of the
peers it had determined to be active in the first loop, in a QList.
It _then_ iterated over the index list, in reverse, calling removeAt()
on the peers list.
<sean parent>That's a remove_if!</sean parent>
The twist is, that only some maximum number of inactive peers should
be removed, just enough to bring the number of peers below a
predefined number.
To solve, use a lambda that keeps track of the number of times it has
returned true, returning false once the count drops to zero. We can't
use a mutable lambda here, since the STL algorithms are allowed to
copy the predicate as many times as they wish, and, indeed, remove_if
is commonly implemented by calling find_if. But the standard
guarantees exactly one application of the predicate per element, so we
can assume that we're not called again on the same element, and
therefore keep a reference to an external count.
With this, what was a horrible mess becomes a single call to remove_if.
Also change a while(--n) c.removeFirst() loop to a single call of
range-erase.
Change-Id: I6c6a54a1805e5b376800e1116e7aec643e95e4e1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Fix warning:
src/corelib/kernel/qmetatype.h:1723:27: warning: ‘T* QWeakPointer<T>::data() const [with T = QFile]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations]
shown when compiling tst_QVariant by using
QWeakPointer::internalData().
Change-Id: I5ea543019b4f8e5dfc829939cd2011ae65f12876
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Java-iterators are going to be deprecated.
Change-Id: I2e6353f3fd9e2ddaf0767e7f6cea713249d9591e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
QDate looked up lengths of months in an array. Change it to use some
simple arithmetic instead. Benchmark result unchanged:
RESULT : tst_QDate::monthLengths():
0.33 msecs per iteration (total: 87, iterations: 256)
Change-Id: I1ab0fa3b97e6716598e50d643a498e0b01c04a96
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The two perform related calculations, so test them together.
RESULT : tst_QDate::monthLengths():
0.33 msecs per iteration (total: 87, iterations: 256)
Change-Id: I86b36a9182b00c0a1f40e858ed3e7812434974c4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When parsing the CLDR data, we only handle language, script and
territory (which we call country) codes if they are known to our
enumdata.py tables. When reporting the rest as unknown, in the
content of an actual locale definition (not the likely subtag data),
check whether en.xml can resolve the code for us; if it can, report
the full name it provides, as a hint to whoever's running the script
that an update to enumdata.py may be in order.
Change-Id: I9ca1d6922a91d45bc436f4b622e5557261897d7f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
It was misnamed local_database, quite missing the point of its name.
Change-Id: I73a4fdf24f53daac12304de1f443636d89afacb2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Use QCOMPARE rather than QVERIFY an equality; ditch a stray blank line.
Change-Id: Ie828837919fb9d3cc774d82d0eebcf7728fed645
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Saves 0.5KiB on optimized GCC 9.1 Linux AMD64 builds, and is more
maintainable going forward.
Change-Id: I11e6dd33eacf276d1205a63734c66fa7c70c5118
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
9204b8c31e broke font matching on Windows.
This was then attempted fixed by bcd2fa484a,
but this caused an infinite recursion for some cases, so it was reverted
again by 9d1905da9c.
The original issue was that if we populate a specific face of a family,
such as "Arial Black", then the typographic/preferred name will be
detected as "Arial" and this family will be set as populated=true, even
though we have not yet registered any additional subfamilies. In this case,
we need to call populateFamily() for the typographic family name to
ensure we get Windows to enumerate all the subfamilies in that family
before it sets it as populated=true.
But this broke for some fonts where the font naming was unconventional.
In particular, "Yu Gothic" would have its Japanese name as the
typographic name, and there would be no font in the system where
the old-style font family name matched the typographic name. In
that case we would go into a loop where we would try populating
"<Japanese font name>", Windows would translate this to "Yu Gothic", we would
translate it back to "<Japanese font name>", ad infinitum.
In order to avoid the infinite recursion, we add a recursion guard
as well, ensuring that we never call populateFamily() for the main
family we are currently populating.
[ChangeLog][Windows][Fonts] Fixed a bug where it would be impossible
to request different faces of a font family after a specific type face
has been in use.
Task-number: QTBUG-74748
Task-number: QTBUG-74983
Change-Id: Ibe6239f67c45d67ebf75947c8f231cfa177e347f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
1) Remove a use-after-move. It was benign because the move didn't
actually trigger move assignment, as the original object was const.
2) Remove a usage of insert(hint), as the hint was always end(),
and there is no reason to believe that that's the insertion place.
Change-Id: I71aac8cdc9fb85b6ecef3695bae7b21f022bb60b
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Unlike any other implicitly shared container, QString/QByteArray
have a "lazy detach" mechanism: their operator[] returns a
special object; assignment into that object will actually
detach.
In other words:
QString a("Hello");
QCharRef c = a[0]; // does not detach
c = 'J'; // detach happens here
This allows this behavior:
QString a("Hello");
QCharRef c = a[0];
QString b = a;
c = 'J'; // detach happens here
assert(a == "Jello");
assert(b == "Hello");
Note that this happens only with operator[] -- the mutating
iterator APIs instead detach immediately, making the above code
have visible side effects in b (at the end, b == "Jello").
The reasons for this special behavior seems to have been lost in
the dawn of time: this is something present all the way back
since Qt 2, maybe even Qt 1. Holding on to a "reference" while
taking copies of a container is documented [1] to be a bad idea,
so we shouldn't double check that the users don't do it.
This patch:
1) adds an immediate detach in operator[], just like all other
containers;
2) adds a warning in debug builds in case QByteRef/QCharRef is going
to cause a detach;
3) marks operator[] as [[nodiscard]] to warn users not using
Clazy about the (unintended) detach now happening in their code.
This paves the way for removal of QCharRef/QByteRef, likely in
Qt 7.
[1] https://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem
[ChangeLog][QtCore][QString] QString::operator[] detaches
immediately. Previously, the detach was delayed until a
modification was made to the string through the returned
QCharRef.
[ChangeLog][QtCore][QByteArray] QByteArray::operator[] detaches
immediately. Previously, the detach was delayed until a
modification was made to the byte array through the returned
QByteRef.
Change-Id: I9f77ae36759d80dc3202426a798f5b1e5fb2c2c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The reason for the explicit qt_GetMessageHook call is not related to
Windows CE anymore. It is a work-around used by the Direct2D
integration.
Change-Id: I489665741fc673ab9d29b35a0c02c51f2a9e9288
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
ASAN reports a leak here, so let's delete the style after the widgets
using them have been destroyed.
Change-Id: I0e8603fc5d2d0c13deca35a1c0020646c65eaf49
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
setHtml() or setMarkdown() can result in attempting to load resources
such as images that are needed to render the page. Whenever the
resource has a relative URL, loading depends on the baseURL having
already been set so that a complete URL can be constructed.
QTextDocument::resource() is called to load images, and uses baseUrl().
A little later, QTextBrowserPrivate::resolveUrl() is given an URL that
already has been extended with the baseURL if known; but it has its own
logic to resolve the resource URL against currentURL, or else to treat
it as a local file path if a file exists at that location. The autotest
was relying on this fallback to the local relative file path before; but
now it tests both with a local filename in the current directory for the
source HTML and also with a fully resolved source URL containing the
complete file path.
Also made minor style improvements in tst_QTextBrowser's TestBrowser class.
Change-Id: I46a850015d0e9c5bc5f13b9e37179a9323ab1980
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
src/corelib/tools/qstring.cpp:9505:clang found diagnostics parsing \fn int QLatin1String::indexOf(QLatin1String l1, int from Qt::CaseSensitivity cs) const error: expected ')' error: out-of-line definition of 'indexOf' does not match any declaration in 'QLatin1String'
src/corelib/tools/qstringview.cpp:723:clang found diagnostics parsing \fn qsizetype QStringView::indexOf(QLatin1String l1, qsizetype from Qt::CaseSensitivity cs) const error: expected ')' error: out-of-line definition of 'indexOf' does not match any declaration in 'QStringView'
src/corelib/tools/qstringview.cpp:822:Unknown command '\t'
src/corelib/tools/qstringview.cpp:825:Unknown command '\t'
src/corelib/tools/qstringview.cpp:826:Unknown command '\t'
src/corelib/tools/qstringview.cpp:831:Unknown command '\t'
src/corelib/global/qnamespace.qdoc:2448:Undocumented enum item 'MarkdownText' in Qt::TextFormat
src/corelib/tools/qstringmatcher.cpp:183:No such parameter 'pattern' in QStringMatcher::QStringMatcher()
src/network/ssl/qsslerror.cpp:58:Undocumented enum item 'CertificateStatusUnknown' in QSslError::SslError
src/gui/kernel/qevent.cpp:5321:Undocumented parameter 'screenOrientation' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent()
src/gui/kernel/qevent.cpp:5321:Undocumented parameter 'screen' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent()
src/gui/kernel/qevent.cpp:5321:No such parameter 'orientation' in QScreenOrientationChangeEvent::QScreenOrientationChangeEvent()
src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockCodeLanguage' in QTextFormat::Property
src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockQuoteLevel' in QTextFormat::Property
src/gui/text/qtextformat.cpp:532:Undocumented enum item 'BlockMarker' in QTextFormat::Property
src/gui/text/qtextdocument.cpp:3294:Undocumented parameter 'features' in QTextDocument::toMarkdown()
src/gui/painting/qcolorspace.cpp:659:Undocumented parameter 'colorSpace1' in QColorSpace::operator!=()
src/gui/painting/qcolorspace.cpp:659:Undocumented parameter 'colorSpace2' in QColorSpace::operator!=()
src/gui/painting/qcolorspace.cpp:659:No such parameter 'colorspace1' in QColorSpace::operator!=()
src/gui/painting/qcolorspace.cpp:659:No such parameter 'colorspace2' in QColorSpace::operator!=()
examples/widgets/doc/src/icons.qdoc:269:Command '\snippet (//! [43])' failed at end of file 'widgets/icons/iconpreviewarea.cpp'
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogRetryButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogYesToAllButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogIgnoreButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogNoToAllButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogAbortButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_RestoreDefaultsButton' in QStyle::StandardPixmap
src/widgets/styles/qstyle.cpp:2026:Undocumented enum item 'SP_DialogSaveAllButton' in QStyle::StandardPixmap
src/testlib/qtestcase.qdoc:439:Undocumented parameter 'TestClass' in QTest::QTEST_HIGHDPI_SCALING_MAIN
src/testlib/qtestcase.qdoc:452:Undocumented parameter 'TestClass' in QTest::QTEST_NO_HIGHDPI_SCALING_MAIN
Change-Id: Ib0e9bf81c5caaa6b1fc644ac92085af47c600e0e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
There's no reason to use them here, the Mutable is misleading in a
few instances, ranged-for is much simpler, and more future-proof.
Change-Id: Ifd5eaae95bbaa0b4cf0f435e6cfee6d778817b44
Reviewed-by: David Faure <david.faure@kdab.com>
They are going to be deprecated soon.
Use a lambda to mimic the adjacent addActions() calls.
Also, I didn't want to add a scope or extend the lifetime
of the return value of actions() until the end of the
function, and
for (QAction *action : actGroup.action())
would detach. I'd've made it a helper function, but it's
used only once, so... a lambda.
Change-Id: I2b3aae463036fd61a9cca7b4ef991b8752869bf3
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Without this some readers will fail to display the image or position
the image at the start of a paragraph rather than inline.
Change-Id: I2b9257e3193e5e68eb20112017a0c23be1d06cb0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
If an embedded image is already encodeded as an png or jpg write the
data as is instead of decoding to a QImage and re-encoding as a new
image.
Change-Id: I479ae1fddbf59900a500497dd1bdf7449c21f273
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
[ChangeLog][QtCore][QSharedPointer] The swap overload for
QSharedPointer in the std namespace has been removed; a new
overload has been added in the Qt namespace.
[ChangeLog][QtCore][QWeakPointer] A swap overload has been
added.
Change-Id: I20d8dd90e896dd9d4b3461dc5d2f5bb2251654da
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Fix some ui glitches for QAbstractSpinBox:
- update geometry when buttons are toggled on/off
- calc button size with subControlRect instead hardcoded 20px
- when buttons are not shown, don't add the button size in
sizeFromContents for common and macOS style
Fixes: QTBUG-39713
Fixes: QTBUG-75303
Task-number: QTBUG-67126
Change-Id: Ibf330c76deb16358a481bba6bd429fff6a5d57ae
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
QScopedPointer uses normal delete, but we need delete[].
Change-Id: Id62a2c55f75ef4aa60580f5e04c4bf306a6dd3c9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The CMake configure_file command is commonly used copy & modify template files
during the build process. One limitation, thought, is that configure_file
expect the variables to be replaced to be encoded using either a @APPNAME@ or
${APPNAME} convention.
This commit therefore changes "APPNAME" to "@APPNAME@" in wasm_shell.html to
make the HTML template file compatible with CMake configure_file.
With this commit, it becomes possible to write the following CMake function
that mimics what QMake is already doing:
function(copy_html_js_launch_files target)
set(APPNAME ${target})
configure_file("${_qt5Core_install_prefix}/plugins/platforms/wasm_shell.html"
"${target}.html")
configure_file("${_qt5Core_install_prefix}/plugins/platforms/qtloader.js"
qtloader.js COPYONLY)
endfunction()
Change-Id: Ic38abdc498ba03b8d21f1b9b70aa1d480ae7f362
Reference: https://cmake.org/cmake/help/latest/command/configure_file.html
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Such files do not exist (as per QFileInfo::exists), but on some
platforms that rely on realpath(), QFileInfo::canonicalFilePath did
not return the empty string.
Use the same logic on macOS as we already did on Android, and include
a test case. Remove the unnecessary dynamic memory allocation and
use a stack-allocated array instead, unless we use modern POSIX in
which case realpath() will alloc the memory for the result for us.
Change-Id: Ide987c68ebf00cbb7b1a66c2e9245a12c7807128
Fixes: QTBUG-44242
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
MinGW doesn't have a debug and a release version of the CRT like
Visual C++ does. Disabling the check would allow distribution
only of a Release build of Qt.
Change-Id: Iecfa753217af96ca74091cd1d47400632629abdb
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Due to PasteboardCopyItemFlavorData converting newlines to '\r' for some
UTIs we have traditionally had to shortcut these UTIs via NSStringPboardType
instead of the mime converters such as QMacPasteboardMimeUnicodeText.
Let's explain this a bit better for future generations.
Note that public.utf8-plain-text doesn't seem to have this problem
anymore, but it's left in for now to not cause any regressions due
to behavior change.
Change-Id: I7dce80828865c6323ed308780b8ca07b7a3e7c17
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
The logic seems to be to prefer public.utf16-plain-text over the UTI
reported by the mime converter's flavorFor, but this doesn't make sense
for two reasons:
1. If the converter reports a UTI from flavorFor, we should respect
that as the preferred UTI. QMacPasteboardMimeUnicodeText already
reports public.utf16-plain-text as expected.
2. We don't know if the converter supports the public.utf16-plain-text
UTI, which is the case for QMacPasteboardMimeTraditionalMacPlainText
for example. The result is that we fail to retrieve any data. The
reason we haven't been seeing this issue is that the code path above
using qt_mac_get_pasteboardString will in most cases succeed and
return early.
Change-Id: I0b7e0d09a97389a229e7a945f17fef74ad5c2fc0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>