When we receive didResignKey notification, before setting active window to
null we check that [NSApp keyWindow] is nil, but it's not. At the same moment,
[NSApp keyWindow] == windowNotification.object - so it's indeed the window that
resigned the key status, it's just NSApp keyWindow that is not nil yet.
Change-Id: Iedc85d806c7d583a2054dc4d7168af13c9c7a4e0
Task-number: QTBUG-49925
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Since placeholderText was using the layoutDirection from the control,
it was always getting LTR since there was no text added yet to the
control. By calling the isRightToLeft function on the placeholderText,
we can determine if it is RTL or not and apply that when drawing the
placeholderText. A change was also made to use the proper elide mode
depending on if it is LTR or RTL.
Task-number: QTBUG-36499
Change-Id: Ic4c9cb9b41d9180185ed35492518152c1122839f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Many callers passed QVariant() as the last ctor argument.
Micro-optimize by providing an overload that default-
constructs the variant in-place.
Change-Id: I9aab40c6e5a025c9a502c706e4cc7b10879ac418
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Takao Fujiwara <takao.fujiwara1@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Q_COMPILER_CONSTEXPR can be undefined (or not defined at all) to
indicate that constexpr should not be used regardless of the compiler's
ability to support it. This is done for QNX because some C library
floating point functions used in the Dinkumware C++ library aren't
constexpr functions; i.e., the library doesn't have proper constexpr
support even though the compiler does.
Change-Id: I16918bbceac1e20b67c6ddbda28df3d9758bab83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QLatin1String can be used as a string-view-like type.
When attempting to do so in uic, mid() and at() were
found to be missing. Added the others for completeness.
Use the new functions in uic, for which they were
originally conceived.
[ChangeLog][QtCore][QLatin1String] Added at(),
operator[](), mid(), right(), left().
Change-Id: I4cfe3e9ed1157dedee754b2012d9678fe72b161e
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Instead of building QStringLists out of statically-known
US-ASCII strings, use C arrays of QLatin1String instead.
QLatin1String is constexpr, so these tables, while causing
relocations, do not require runtime initialization.
Using QStringBuilder, these QLatin1Strings are almost a
drop-in replacement for the QStrings used before.
Effects on optimized GCC 5.3 Linux AMD64 builds:
$ size bin/uic-*
text data bss dec hex filename
567104 31776 56 598936 92398 bin/uic-00-before
565829 31944 24 597797 91f25 bin/uic-01-after
Change-Id: I469c62b0e8966731d7ac2fa092f4b4cd8ddb79f1
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This fixes a link error due to symbol visibility when the iOS
platform plugin is built as a shared library.
Change-Id: I0b454c5c5033c6b598cede11ce5e3a85e5704c4a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Fix warnings in file qwindowswindow.cpp. Remaining part of a refactoring
done in the 5.6 branch.
Task-number: QTBUG-50804
Change-Id: I4d7b423e0802ac39109c30c0de615664d3ee9216
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
SavedPersistent is larger than a void*, so holding it in QLists
is needlessly inefficient. Worse, the code could come to depend
on the fragile property of (inefficient) QLists that references
to elements therein never are invalidated.
Fix by marking it movable and holding it in a QVector instead.
Take advantage of rvalue-enabled QVector::push_back(); optimize
element construction by using aggregate initialization.
Change-Id: I4fd88879aa13e6536d59d164b3c33fbc2fead77f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
These types are larger than a void*, so holding them in QLists
is needlessly inefficient. Worse, the code could come to depend
on the fragile property of (inefficient) QLists that references
to elements therein never are invalidated.
Fix by marking them movable, and holding in a QVector instead.
Change-Id: I78774fc78d787241aaadc4f819b6d229e6200f46
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Also reserve a QList in QPrinter::supportedPaperSources().
Change-Id: I94d24b81d7adcad2b28d36efdbef5a8726412f1a
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
A QList<QPair<int,int>> is one of the most dangerous ones, because
it fundamentally changes memory layout, and therefore performance
and invariants, when going from 32-bit platforms (array list) to
64-bit (vector-like).
Port to QVector instead, which has a consistent design across all
platforms.
Also port from QPair to a simple struct { code, depth }, because
member names such as 'first' and 'second' have no semantic value
and make code using them very hard to understand.
Change-Id: I86c95d78dbb2e82ec222d6eae8ba11568e3ff0af
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Change-Id: I86afe7104d506b840130517ae8066588fab2d745
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
- Instead of a QStringList, use a const char 2D array
to hold the system user names. Don't remove the
current user from that list, skip it duing processing.
- Extract Method make_where_clause, optimize it and
cache its result. Instead of creating a QStringList
and join()ing it at the end (sometimes twice), append
to the result QString directly. Reserve the max size
of the result string, which is statically known.
- Keep the query select statements in QLatin1String.
They are only used in QStringBuilder expressions.
Change-Id: I0593d2812da671a541d49a6136f3ff3d784c63d5
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
It's private API, so we can.
As a consequence, had to add nothrow member-swap and, in
QMimeGlobPattern, remove the user-defined empty destructor
to un-inhibit the (nothrow) move special member functions.
Change-Id: If5bb72db3c823c7b0e372f9bec99c7242d11839b
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
It didn't make the class implicitly shared, but required an
additional heap allocation on construction and copy, as it
used 'only' QScopedPointer. As it's private API the pimpl
is also not needed for BC reasons.
So inline the data members, and some trivial accessors.
As a by-product of removing the copy special member functions,
we gain nothrow move special member functions.
Interestingly, the memory layout of a QList<QMimeMagicRule>
(replacing which is the topic of a future patch) doesn't
change due to this change, because the type that formerly
fit QList very well now is too large. But copying the type
outside QList now no longer allocates memory.
Saves more than 2.5KiB in text size on optimized GCC 5.3
Linux AMD64 builds.
Change-Id: Ie3588cb5693227da6f1bfa196db924e075a750b3
Reviewed-by: David Faure <david.faure@kdab.com>
... instead of re-evaluating its expression. More readable.
Change-Id: I18c6ab3bbc4c5a14328f9910fab991f6cad5549d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Saves around 0.5KiB in text size on optimized GCC 5.3
Linux AMD 64 builds.
Change-Id: Iaf2664e670a96136031bac67e4012d4f7324eb47
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Simplifies the code and is also more efficient, because
it copies less data.
Change-Id: I9ad0c372fb4fa6f5818d9d6cb7b7cf35935f8565
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This changeset enables running a QCoreApplication from within an Android
Service. The Android Application running can now have a QtActivity or a
QtService, but having both in the same process is not supported.
This patch was based on Cory Slep's patch
[ChangeLog][Android] Qt can now be used to easily create Android Services.
Task-number: QTBUG-37221
Change-Id: I0fd693daaa85b991940ffe9cc41c483022677199
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
In recent Xcode versions it doesn't work as expected, and caused build
failures in downstream modules, so we disable it until the cause can
be investigated further.
Change-Id: Ie54c7256a10d73610ec7e481b9d665b75e396365
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Pass modeltest after clear(). Otherwise it fails because more flags
than Qt::ItemIsDropEnabled get returned for the QModelIndex().
Change-Id: I8f11515cc7dc9383f528f785312ffb77b3c2699d
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This method does not modify the object.
Can't change the API, so overload and mark the old function
for removal in Qt 6.
Change-Id: I4aee2bc19209646adc21388375aedd20a09129d0
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
The attribute can be set to suppress native dialogs for example
for testing purposes.
Task-number: QTBUG-51074
Change-Id: I35611e07e00b7a060f22b49d6ab6f3b8627f8aca
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Change-Id: I2e95456146b6ce646e244e962082f2967bcaed42
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
So far we've been dependent on the focus behavior setting in OS X
system preferences. This change allows us to start testing both
behaviors on any platform.
Change-Id: I9ce004f8b9479f8e722a387b795de16edb166a07
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
- Use splitRef() instead of split(), avoiding small temporary
QStrings.
- Don't remove all spaces before splitting, trim strings at
the QStringRef level later, where needed. This will reject
nonsense strings like QSQL_ LITE _BUSY_ TI MEOUT= 1 2 3 that
were previously (wrongly) accepted.
- Use C++11 range-for loop.
Change-Id: I875c4cf47b7a283ba55783f70c903bb9947e1cd7
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This allows methods that return an icon name, to sometimes also
return an icon full path (e.g. because the icon was dynamically generated
and stored into a local cache on disk)
Change-Id: Ib01c3955f4b64236463846241d9814b2d0686634
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
m_activity.getActionBar() returns null when a .NoActionBar theme is
declared in AndroidManifest.xml file
Change-Id: I671891d03913209c3f9f34a6f4dd8894c20de5c2
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
... and loops.
Every QNetworkConfiguration::bearerType() call produces lock/unlock of mutex.
Fix: cache result.
Every QHttpNetworkRequest::contentLength() call contains internal loop.
Fix: cache result.
Also cache results of QNonContiguousByteDevice::size() and
QHostAddress::protocol().
Change-Id: I01124648b1972f480905433d9b3551c2246e1bde
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Profiling shows that the call to glGetIntegerv() in this function that
queries for the currently bound framebuffer is very expensive. It's
the top hit on the CPU when profiling a Qt3D application using a
Scene3D Qt Quick 2 item. The reason it is so expensive is that this
call forces the OpenGL driver to propagate the OpenGL state through
all of the queued commands in order to answer the query. It may
also induce a pipeline stall depending upon the driver implementation.
As this function gets called on the hot path every frame whenever using
a Scene3D item and may also be called in plain Qt Quick when using
ShaderEffect items; the layer property of QQuickItem; or when updating
the Qt Quick glyph cache texture on Core profile contexts, it is very
much worthy of optimization.
This commit adds an overload of the blitFramebuffer() call that allows
the caller to provide a policy that can either:
* keep the existing behavior of restoring the previous framebuffer
binding,
* restore the default framebuffer, or
* don't restore anything and let the caller be responsible for it.
This will allow consumers such as Qt Quick and Qt 3D to use the
optimised code path. The existing overloads of blitFramebuffer()
retain the current behavior by calling with the policy to restore the
previous framebuffer binding.
Upon making this change, the cost of blitFramebuffer() is massively
reduced. A follow up commit will optimize this further.
Change-Id: I417abb7da916ae5088f6817e4eff8ea02c8c5803
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
caught with static analyzer which only warns for trivial cases:
- Container must be local
- Container isn't passed to any function, assigned to another
container or assigned to.
Change-Id: I3f3aa73c128a56f067fa8745990977445a495ac4
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Similar to QMap::equal_range().
Will allow to easily fix inefficient code such as:
foreach (auto value, hash.values(key)) { ... }
[ChangeLog][QtCore][QHash] Added QHash::equal_range()
Change-Id: I6e19e25de632e897ad83d3141d9d07f0313f7200
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
I didn't add a transpose(), because r = r.transposed() is
perfectly capable of filling that role, and just as
efficient. Existing API mistakes are no excuse to create
more of them.
[ChangeLog][QtCore][QRect/QRectF] Added transposed().
Change-Id: Ic38721e9028496fc9b50f4d4cef2e7a60532eed8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
After this change, this was the distribution of calls in
QtGui and QtWidgets when the patch was developed for 5.4:
QtGui QtWidgets
move 23 63
copy 23 36
Change-Id: If3f536e52fc242c585e7fa0662049c0657efcc9c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
QFlags::setFlag is most useful to replace explicit constructs like
if (condition) {
someFlags |= TheConditionFlag;
} else {
someFlags &= ~TheConditionFlag;
}
with
someFlags.setFlag(TheConditionFlag, condition);
Change-Id: Ie4586681c83e0af812d5bbf14965aad51941a960
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This patch makes sure that all events posted using Qt on top of the
GLib event loop have the loopLevel counter incremented.
This is done since Qt depends on the fact that all deleteLater() calls
are issued within the scope of some signal handler (in other words,
triggered by the chain sendEvent() -> notifyInternal2()).
There is a side effect though: in the conditions affected by this
patch, that is deleteLater()s issued within a glib event handler for
example, manually calling processEvents() or sendPostedEvents() with
or without the QEvent::DeferredDelete flag has the same effect, and
deferred deleted events are always processed.
While this is not a currently working feature which the patch breaks,
this side effect seems to be difficult to avoid without separating
sendPostedEvents() and processEvents() into a public and a private
method, in order to detect when they are manually called.
Such change could perhaps be done for Qt6.
An autotest for QTBUG-36434 is also included.
Autotesting for QTBUG-32859 seems to be more challenging in this
respect, due to its dependency on GLib.
Task-number: QTBUG-18434
Task-number: QTBUG-32859
Task-number: QTBUG-36434
Change-Id: Ib89175aa27c9e38bca68ae254d182b2cd21cf7e9
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
The user-defined copy assignment and copy constructors
inhibit the move special member functions.
We cannot do something about it in Qt 5, because the
class is exported (which it shouldn't be), and because
making it trivially-copyable might change how it is
passed to functions by value, so we need to supply all
the missing member functions manually.
Change-Id: Ic710b449f6abd386449fa6df71e8bc9bd0f98d2b
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>