All four manager classes contained roughly the same code in their
ctors that parsed out devices from a colon-separated string.
Extract shared code, and port the parsing to QStringRef (later to be
ported to QStringView).
Saves ~2.4KiB on optimized Linux GCC 9.1 AMD64 builds across all
.so's that link to libQtInputSupport.a.
Change-Id: I3db826ee2b422cfc02f8d49bd21985a03b6c0935
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
To not write into a shared object without mutex protection. If the
stored icon name is empty, just calculate a new one on each call.
Task-number: QTBUG-45684
Change-Id: I01dfb6697b5275e69451da91fdc7346f40bc424e
Reviewed-by: David Faure <david.faure@kdab.com>
Make create() return, and m_mice/m_keyboards/etc store, handlers by unique_ptr.
In most cases, we can't use qt_make_unique(), since the ctor we're calling is
marked as private.
Since QHash can't hold move-only types, use a std::vector<{QString, unique_ptr}>
instead. As this pattern repeats in all four QEvdev*Manager classes, create a
small class template.
Saves almost 6KiB on optimized Linux AMD64 GCC 9.1 builds across all .so's that
link to QtInputSupport.a.
Change-Id: I8f62b6b629d6e1855314c0a4fb4fc069db9ae0ce
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
QExplicitlySharedDataPointer is propagating const in my tree, and I will be proposing
this for inclusion into Qt 6, so proactively fix the breakage here.
QMimeType is known to be non-reentrant (QTBUG-45684), and this patch doesn't fix it.
Change-Id: If68b148c44439d76ab1d95e8db93b90d12650e51
Reviewed-by: David Faure <david.faure@kdab.com>
It's needed to prepare qtdeclarative for the upcoming patch that
won't make QGradient accept illegal presets any more.
Change-Id: I4ca929e75214ebe24c7d762d0c37ca254c640c57
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
... and replace them by C++11 range-for loops.
Change-Id: I6975121f606ec1fcda7a624b02a68edf829bb70b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
The code is noisy and repeats, so wrap it in a function.
Change-Id: I5e6e924e22b0bc631eb8176de96c49066b1c9029
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Dealing with 'tokens' is straight-forward.
With 'literals', it is not quite so straight-forward, because the
ownership chain here is two levels deep. But it's still worthwhile,
because it replaces quite error-prone code with code which may be a
bit more verbose, but is totally safe.
As a drive-by, moved initialization of the fromEnvironment member to
the body of the ctor in order to avoid code-churn (I needed to touch
the ctor-init-list anyway).
The QMessagePattern dtor is now empty and consequently defaulted.
Change-Id: Iadb25e7aba1c5a94fd9068be7ae03f17e975328b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Wait for the result at the target index if the future
is running and the iterator index is past the current
result count.
Determine if there is a result at the target index
after waitForResult() returns, and return -1/end if
not.
Also support decrementing the end iterator. In this
case wait for the future to finish in order to get
the final result count.
Task-number: QTBUG-59811
Change-Id: I8fcc711bab2e72c3c5196a55b794d25e18bb324d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
- Use range-based for
- Use isEmpty() instead .size(), streamline code
- Fix warnings about class definitions, use Q_DISABLE_COPY_MOVE
and '= default' for trivial constructors
Change-Id: I76255fd9d80c3faffebda9a438e86e918c16d289
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Fix warning like:
warning: use auto when initializing with new/reinterpret_cast to avoid duplicating the type name [modernize-use-auto]
Change-Id: Ieb7f052919173f6923e68de9f9e849dee45e36e7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
The Vulkan backend of QRhi relies on vk_mem_alloc.h from AMD in order
to get a stable, performant, and tested GPU memory allocator. It is not
unthinkable that we will move away from this in the future, especially
considering that a potential future D3D12 backend may need a similar
solution, but until then this will do.
Change-Id: I198a898f216d0795b4bf339ccea80b0cd2efbabc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Comes with backends for Vulkan, Metal, Direct3D 11.1, and OpenGL (ES).
All APIs are private for now.
Shader conditioning (i.e. generating a QRhiShader in memory or on disk
from some shader source code) is done via the tools and APIs provided
by qt-labs/qtshadertools.
The OpenGL support follows the cross-platform tradition of requiring
ES 2.0 only, while optionally using some (ES) 3.x features. It can
operate in core profile contexts as well.
Task-number: QTBUG-70287
Change-Id: I246f2e36d562e404012c05db2aa72487108aa7cc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
If the mouse button is held and mouse moves from over the window, that
window would never register the button up event, and cause issue like
being able to move a dialog around by simply moving the mouse around.
Change-Id: I1363ac9c9f4113a79bf6863668ba74b90b1cea4a
Fixes: QTBUG-75951
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
The declaration of tr() in the Q_OBJECT macro interferes with the
tr() declaration in the QObject class. This update fixes that bug
by resetting QT_TR_FUNCTIONS to be empty and by ensuring that the
tr() declaration in class QObject is seen by clang when qdoc is
running.
Change-Id: If55339fc417f3eee1a1e1ce3df75a18af443d630
Task-number: QTBUG-75864
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
The problem becomes visible with styled native text materials in Quick,
but only in certain cases: the regions not used by glyphs in the QImage
are undefined (if they are 0 there's no problem) - but the whole
code path is only used when the fbo readback workaround is enabled.
When these conditions met, the styled text materials may sample locations
with uninitialized data in the texture, showing small artifacts around
the glyphs when shifting is involved in the styling.
The non-image based GL glyph cache handles this by an explicit upload
with all 0's when creating the texture - the QImage code path should do
the same then.
Change-Id: I818ee19f87c6a147e42cd3ead39645da4d0fef11
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
[ChangeLog][qmake] Introduced the variables LEX_DIR and YACC_DIR which
determine the location of lex/yacc output. Fixed parallel execution of
lex/yacc for debug_and_release builds.
Fixes: QTBUG-65730
Change-Id: I68c8260a95609e11bb5205a91aff2c098ed7009c
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Elements that appear in QMAKE_DIR_REPLACE_SANE must appear in
QMAKE_DIR_REPLACE to be considered due to the algorithm used in
exclusive_builds_post.prf.
Change-Id: Ibce7e6c988b3e8a141075890a2f547eb34090b3a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
... except where they are actually the component under test.
Java-style iterators are scheduled for deprecation.
Change-Id: If4399f7f74c5ffc0f7e65205e422edfa1d908ee8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
also fix data progress
Task-number: QTBUG-75489
Change-Id: I5222fda64d258a6ae78ba0ca20194b81c289c27e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
They are going to be deprecated.
Add a strategic break. This was a pre-existing problem: the comment
claims that h is invalid (though I personally don't see it), but
then goes on to check the loop condition (which, in the mutable
Java iterator case, involves calling h.cend()). We now cache the
end iterator, so if there ever was a problem, it's probably a
lesser one now, but it's still not kosher, and a debug version of
QHash would find it, so break out explicitly.
Saves ~200b in text size on optimized GCC 9.1 Linux AMD64 builds,
ie. ~100b per loop.
Change-Id: I7684485b55fb23a8cf882f89621ebb75a0e607b5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This requires making QDebugStateSaver hold QDebug::Stream directly, not
QDebug by reference, as the referenced object will have been moved from
when ~QDebugStateSaver executes. The stream object, however, will still
be around.
Change-Id: I0ca2eb60cb9b68ea3835d9a9ff5e295d9b1c5fb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
QSaveFile should preferably be used by editor applications to catch
write errors.
Task-number: QTBUG-60635
Change-Id: Ia609435871b56b45714c3dd3d32bbc85b5cb4dd5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Also use qUtf16Printable() and qErrnoWarning (removing explicit errno, where
present).
Saves 6.6KiB in text size on optimized Linux AMD64 GCC 9.1 build across
all .so's that link to QtInputSupport.a.
Change-Id: I1def2cfabd2eed65390099cd1d06f8061a9355be
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The only reason the code used QSharedPointer is that it used QVector
to hold a collection of them, and QVector infamously cannot hold
move-only types such as std::unique_ptr.
Fix by using std::vector<std::unique_ptr> instead. Also, pass the
objeccts into non-sink functions by raw pointer instead of shared_ptr.
As a drive-by, replace clear-following-iterate by the for-exchanged
pattern.
Change-Id: I605fbb98af840c1b93eab9e65c07defd6e7b39e1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Extracted from the SVG names patch.
It basically just requires adding a constexpr constructor to the
inner union, then sprinkling constexpr on the existing ones.
Do minor refactorings as drive-by.
Change-Id: I60e7a1c9068def3507cb07440450e51673269f84
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
strlen on literals gets typically optimized out nowadays.
Adjust callee side to handle the off-by-one between sizeof(literal)
and strlen().
Change-Id: I1551f69a160922681d66024701ba1bd8f6dc03bf
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
The previous work-around fails, probably because of
cross-dependencies. E.g. we have this in QtScXml:
In file included from /home/qt/work/install/include/QtCore/qsharedpointer.h:48:0,
from ../../src/scxml/qscxmltabledata_p.h:55,
from ../../src/scxml/qscxmltabledata.cpp:40:
/home/qt/work/install/include/QtCore/qsharedpointer_impl.h:687:12: error: ‘QPointer’ does not name a type; did you mean ‘pointer’?
friend QPointer<X>
^~~~~~~~
pointer
/home/qt/work/install/include/QtCore/qsharedpointer_impl.h:689:23: error: ‘QSmartPointerConvertFunctor’ in namespace ‘QtPrivate’ does not name a template type
friend QtPrivate::QSmartPointerConvertFunctor<QWeakPointer>;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
To fix, grand friendship only to a non-template class with a templated
static method that returns internalData(). This fixes most users,
except in qmetatype.h, which does not include qsharedpointer.h. In
order to use the non-template class in there, we need to delay its
name lookup to instantiation time. We do this by artificially making
it a dependent name, by using a class template that inherits from
our befrieded class.
Change-Id: I12b427f1fe9503df819ea5436d780972d6402e68
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
C++11 allows non-POD-types in unions, so the test didn't test anything.
Use a static_assert over std::is_pod instead.
Change-Id: Ida7ef0551ae6ae07357a987a409294d2a386be2f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
The check was a misnomer -- non-POD types can go in unions
since C++11. And we may want them, e.g. types without a trivial
default constructor. What we really want is to check for a
literal type (so that the array payload can be built entirely
at compile time, and put in .rodata). So, amend the check.
Also, make the dummy array constexpr, to be sure that we are
indeed building the payload using constexpr constructors.
That would make the first check redundant, but the fact that
we're still using a macro for constexpr makes me think that
not all compilers support it, so I'm leaving the first check
in...
Change-Id: I9f1473aa74dff5b6b6535ae4cd8325451c0b18e6
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Plain load() / store() have already relaxed semantics. This
can be surprising -- std::atomic::load()/store() are actually
sequentially consistent -- and introduce a pain point
if someone wants to move from Qt atomics to std:: atomics.
So just add a suffix to the functions to clarify what's the
memory ordering involved with them.
The Ops::load / ::store are temporarily left in, because other
modules depends on them. We need to port those modules away,
then they can go (it's private API anyhow).
Similarly, not deprecating anything yet, except for marking
obsolete in the docs; there's a lot of code around using
load() / store() that needs to be ported first.
[ChangeLog][QtCore][QAtomicInteger] Added loadRelaxed() and
storeRelaxed(), to be used as replacements of load() / store().
[ChangeLog][QtCore][QAtomicPointer] Added loadRelaxed() and
storeRelaxed(), to be used as replacements of load() / store().
Change-Id: Iab0a78885050379e3740f0b039ba2bef28ce3bd2
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The calendar APIs shall need fromShortMonthName() to know its year
number; so rearrange the date parsing that uses it to ensure the year
number is known in time. In the process, pass &ok to toInt() also for
the calls that get a day number (where failure's 0 return is an
adequate check for failed parse), just to be on the safe side.
Change-Id: Id09c40da9f7e70e68be440e9805a3d30a80977c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Cleans up most of corelib to use nullptr or default enums
where appropriate.
Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Also remove it from versions no longer supported.
Change-Id: I03a911a349527a81846e1820f95d775fe3943450
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
RTEMS does not support poll/select and etc for files and
fcntl(fd, F_GETFD) can not say that.
Change-Id: If5ad160cd81e347fac72d2bafcb5b5bb815ed059
Reviewed-by: Ryan Chu <ryan.chu@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The calculation of page position of table headers would only work
correctly for tables in the root frame of a QTextDocument. Fix by
including the relative positions of subframes.
Fixes: QTBUG-59000
Change-Id: I2cc7e21bddf806f7f5f9b0675ac014c339ba2453
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>