Commit Graph

27208 Commits

Author SHA1 Message Date
Marc Mutz
8005fa3524 QStringRef: add missing relational operators against QLatin1String/QString
Equality and inequality were already provided. Missing were the
less/greater than (or equal) operators.

Added.

Moved existing functions around and more similar to the new ones,
to make the whole code section a bit more manageable.

[ChangeLog][QtCore][QStringRef] Added missing operator{<,>,<=,>=}
comparing against QLatin1String and QString.

Change-Id: Idb3c4fa9b38421637987226f3cc1b77f5d4a6309
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-16 08:06:54 +00:00
Sérgio Martins
c4b52b42ab gui: Pass large types by const-ref
sizeof:

Operator            : 144
QTransform          : 88
QGlyphLayout        : 48
QTextFrame::Iterator: 32
QRectF              : 32
QCss::Value         : 24

(Linux/x86_64)

Change-Id: I4965bf0959683c0bc8909428fca86d66851af92c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-03-15 21:25:59 +00:00
Alex Trotsenko
5dc13fe05e QIODevice: allow zero-copy in read()
Try to prevent the data from being copied, if we have a chunk with the
same size in the read buffer.

Task-number: QTBUG-19169
Change-Id: I2a9a5c88855988888b56d0ca69ec4e50b8e6ef98
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
2016-03-15 20:27:00 +00:00
Lars Knoll
d1b09dba45 Remove the c++default test
This test was the old way of checking whether to enable
c++11 functionality. That is now anyway required, so there
is no need for this test anymore.

Change-Id: I083e85a4698cac6bd9b573525c7b977f63e14113
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-03-15 16:45:25 +00:00
Lars Knoll
a332a7d6c3 Remove support for the obsolete -no-zlib configure arg
Simplify the handling in the pro files as well. system-zlib
is the only option deciding whether we use our bundled copy
or the system lib.

Change-Id: Id28c1c64c5944e86f0e9cd3533268f43e98522a1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-03-15 16:45:19 +00:00
Alex Trotsenko
510272ce6c QAbstractSocket: do not try to disable write notifications twice
When canWriteNotication() is called and the socket successfully writes
a chunk of data, then condition for disabling the notifications will be
checked both in writeToSocket() and canWriteNotification(). Moving the
code which handles notifications' state from canWriteNotification() to
another branch in writeToSocket() eliminates a duplication and forces
writeToSocket() to handle disabling the notifications in all cases.

Change-Id: I6c14db552afe77b0cf1c9f5c511bafa127a45fe5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
2016-03-15 16:41:30 +00:00
Lars Knoll
3d3b056f89 Remove openvg tests from configure
We're not currently supporting OpenVG anywhere, so remove
those tests. If we need them in the future, it's easy to get
them back.

Change-Id: I06c0f9f3b3ecaa10a51de84c3059d4eee3a29fad
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
2016-03-15 11:47:52 +00:00
Marc Mutz
032efc2cb2 Add test for API symmetry of QString/Ref, QLatin1String, QChar
At the moment, only checks the relational operators, where
it already found some which do not compile. In order to
simplify the test, the missing operators are supplied by
the test harness until they are fixed in the library.

Change-Id: Ief5daefa68f15de5f8e559c9378ed83b715b69ee
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-15 08:11:35 +00:00
Aram So
a7fc1cef91 Add environment variable QT_DISTANCEFIELD
DistanceField technique was not intended for rendering very large glyph.
In some case need the qEnvironmentVariable.

Change-Id: Ied11ed00f0c67bae3c92155e17721d8d2f224cca
Task-number: QTBUG-51714
Reviewed-by: Aram So <aram.so@lge.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
2016-03-11 10:44:19 +00:00
Friedemann Kleint
2ec7f2cfed QSql tests: Remove Windows CE and clean up code.
Use the newly introduced QSysInfo::machineHostName() to determine
the host name in the shared header, removing the need to link
against the winsocket library. All Windows-specific .pro sections
can then be removed.

Task-number: QTBUG-51673
Change-Id: Iba990b886b16addd210639871065abde6de96516
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
2016-03-10 15:07:02 +00:00
Friedemann Kleint
e82bdee165 QFactoryLoader: Add namefilter for Windows.
No longer try to load all files in the directory as a plugin
which can cause problems when for example installers move
files around.

[ChangeLog][QtCore][QFactoryLoader][Windows] QFactoryLoader now
filters potential plugins by the ".dll" suffix.

Task-number: QTBUG-31476
Change-Id: Ia19d6211c72765aaba0a5d06e6d3b501e8a40fff
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-10 15:05:55 +00:00
Joerg Bornemann
52623d6d9d qmake: Remove Windows CE support.
The platform has been removed in Qt 5.7.

Change-Id: Ie768b5ffbe60270c27b4a670dcf580ea361cb361
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-03-10 13:33:44 +00:00
Friedemann Kleint
390598cb43 Winmain: Remove Windows CE.
Remove #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library.

Task-number: QTBUG-51673
Change-Id: I473f215066db819a273f293940dcce9fe03152c3
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
2016-03-10 13:28:13 +00:00
Alex Trotsenko
8042c5243c QAbstractSocket: remove unnecessary checks
There is no need to check the 'enabled' states before calling
set{Read|Write}NotificationEnabled() functions, because the socket
event notifiers are fully optimized for this case.

Change-Id: I0cd4fbc2298c9b9523420a60a46a65e0b305fa12
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-03-09 15:51:32 +00:00
Friedemann Kleint
feca9d95c1 Add missing "We mean it." warning to qnetworkfile_p.h.
QtNetwork: WARNING: qtbase/src/network/access/qnetworkfile_p.h does not have the "We mean it." warning

Task-number: QTBUG-45925
Change-Id: I9cd9237450101c4c862746e774fa37d69083c213
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
2016-03-08 15:17:19 +00:00
Friedemann Kleint
b09ce612fc QNetworkFile: Fix compile error with MinGW/gcc 5.1.
access\qnetworkfile.cpp: In member function 'void QNetworkFile::open()':
access\qnetworkfile.cpp:69:93: error: invalid use of incomplete type 'class QDateTime'
         headerRead(QNetworkRequest::LastModifiedHeader, QVariant::fromValue(fi.lastModified()));

Task-number: QTBUG-45925
Change-Id: I61ff67f9691fe7b6966353e29eeb03d37590d78d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
2016-03-08 11:26:57 +00:00
Jesus Fernandez
8c86d57e32 Async open file support in QNetworkAccessManager
This change adds support for BackgroundRequestAttribute to local file request. It is useful
when opening files located in network drives where the file open operation could take several
seconds to complete. When this attribute is activated the QNetworkAccessManager::get call
returns the reply immediately and the user has to wait until QNetworkReply::finished signal
is emitted or QNetworkReply::isFinished function returns true.

Task-number: QTBUG-45925
Change-Id: Ie2019dd94fe04253d1ef6874811d7e749a5aad93
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
2016-03-07 18:07:37 +00:00
Fredrik de Vibe
95ea7552a1 Rename test to comply with coding conventions.
Test was inappropriately named according to
https://wiki.qt.io/Writing_Unit_Tests#Naming_of_test_functions_is_important

Task-number: QTBUG-51288
Change-Id: I1c97cee80b5fbf41182b9472ba683862a576b83c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
2016-03-07 15:02:23 +00:00
Mike Krus
8defe0f4e3 Remove iOS/OS X duplication
Move common configuration to mac

Change-Id: Ic4a6ad896ac6fd46a0914a267ba87adecc6b37e4
Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
2016-03-05 22:20:24 +00:00
Fredrik de Vibe
48f25caac4 Check if socketEngine is set before accessing it.
QTcpServer::addPendingConnection() is protected, so it is possible to
add pending connections from a class derived from QTcpServer. This
derived class can get a QTcpSocket from somewhere else, in which case
d->socketEngine will not be set (or used). Given that it is possible to
add pending connections in this scenario, it would make sense to be able
to retrieve them as well.

[ChangeLog][QtNetwork][QTcpServer] Permit using a QTcpServer with
externally created QTcpSocket.

Task-number: QTBUG-51288
Change-Id: I830c10f1a881e2bca4e4ad716d8be865e1c27a9f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-04 08:11:54 +00:00
Milian Wolff
954bd06bc5 Use local result metric instead of global result metric.
This is required for a follow-up commit which adds support for reporting
multiple results in a single benchmark interation.

Change-Id: I8dd7f37ce046cc0f9556be5d0df76f84b82ec1a7
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-03-03 09:56:08 +00:00
Milian Wolff
8619214c5e Optimize QMetaObject::activate.
The code is restructured to only loop over the non-empty connection
lists. This can be checked early while the mutex is locked already,
thus removing mutex lock/unlock calls that were done previously just
to realize the allsignals list is empty and can be skipped.

Additionally, at the very end of the loop over the last signal
connection list, the mutex was acquired even though it doesn't need
to be as we will quit the loop anyways.

This patch leverages these facts to remove the mutex locks which alone
has a considerable impact on the corresponding signal/slot benchmark.
The instruction count goes down by ca. 13%, while cycle count and
runtime drop by about 29%.

Before:

********* Start testing of QObjectBenchmark *********
Config: Using QtTest library 5.7.0, Qt 5.7.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.0)
PASS   : QObjectBenchmark::initTestCase()
PASS   : QObjectBenchmark::signal_slot_benchmark(simple function)
RESULT : QObjectBenchmark::signal_slot_benchmark():"simple function":
     0.00000362 msecs per iteration (total: 362, iterations: 100000000)
     14.05652884 CPU cycles per iteration (total: 1,405,652,884, iterations: 100000000)
     21.00585673 instructions per iteration (total: 2,100,585,673, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(single signal/slot)
RESULT : QObjectBenchmark::signal_slot_benchmark():"single signal/slot":
     0.00004709 msecs per iteration (total: 4,709, iterations: 100000000)
     183.75943370 CPU cycles per iteration (total: 18,375,943,371, iterations: 100000000)
     362.08604759 instructions per iteration (total: 36,208,604,760, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(multi signal/slot)
RESULT : QObjectBenchmark::signal_slot_benchmark():"multi signal/slot":
     0.00004965 msecs per iteration (total: 4,965, iterations: 100000000)
     183.54556242 CPU cycles per iteration (total: 18,354,556,243, iterations: 100000000)
     362.07734835 instructions per iteration (total: 36,207,734,835, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(unconnected signal)
RESULT : QObjectBenchmark::signal_slot_benchmark():"unconnected signal":
     0.00000752 msecs per iteration (total: 752, iterations: 100000000)
     30.08781366 CPU cycles per iteration (total: 3,008,781,367, iterations: 100000000)
     92.01520465 instructions per iteration (total: 9,201,520,466, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(single signal/ptr)
RESULT : QObjectBenchmark::signal_slot_benchmark():"single signal/ptr":
     0.00005620 msecs per iteration (total: 5,620, iterations: 100000000)
     219.24739264 CPU cycles per iteration (total: 21,924,739,265, iterations: 100000000)
     327.08675555 instructions per iteration (total: 32,708,675,556, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(functor)
RESULT : QObjectBenchmark::signal_slot_benchmark():"functor":
     0.00005852 msecs per iteration (total: 5,852, iterations: 100000000)
     218.45401359 CPU cycles per iteration (total: 21,845,401,360, iterations: 100000000)
     328.08472410 instructions per iteration (total: 32,808,472,410, iterations: 100000000)
PASS   : QObjectBenchmark::cleanupTestCase()
Totals: 8 passed, 0 failed, 0 skipped, 0 blacklisted, 44469ms
********* Finished testing of QObjectBenchmark *********

After:

********* Start testing of QObjectBenchmark *********
Config: Using QtTest library 5.7.0, Qt 5.7.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.0)
PASS   : QObjectBenchmark::initTestCase()
PASS   : QObjectBenchmark::signal_slot_benchmark(simple function)
RESULT : QObjectBenchmark::signal_slot_benchmark():"simple function":
     0.00000361 msecs per iteration (total: 361, iterations: 100000000)
     14.01854817 CPU cycles per iteration (total: 1,401,854,818, iterations: 100000000)
     21.00532932 instructions per iteration (total: 2,100,532,933, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(single signal/slot)
RESULT : QObjectBenchmark::signal_slot_benchmark():"single signal/slot":
     0.00003398 msecs per iteration (total: 3,398, iterations: 100000000)
     132.52735104 CPU cycles per iteration (total: 13,252,735,104, iterations: 100000000)
     314.04965106 instructions per iteration (total: 31,404,965,107, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(multi signal/slot)
RESULT : QObjectBenchmark::signal_slot_benchmark():"multi signal/slot":
     0.00003448 msecs per iteration (total: 3,448, iterations: 100000000)
     133.63623046 CPU cycles per iteration (total: 13,363,623,046, iterations: 100000000)
     314.04952237 instructions per iteration (total: 31,404,952,238, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(unconnected signal)
RESULT : QObjectBenchmark::signal_slot_benchmark():"unconnected signal":
     0.00000747 msecs per iteration (total: 747, iterations: 100000000)
     29.02349389 CPU cycles per iteration (total: 2,902,349,390, iterations: 100000000)
     92.01088221 instructions per iteration (total: 9,201,088,222, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(single signal/ptr)
RESULT : QObjectBenchmark::signal_slot_benchmark():"single signal/ptr":
     0.00004350 msecs per iteration (total: 4,350, iterations: 100000000)
     167.83581885 CPU cycles per iteration (total: 16,783,581,885, iterations: 100000000)
     279.06426656 instructions per iteration (total: 27,906,426,657, iterations: 100000000)
PASS   : QObjectBenchmark::signal_slot_benchmark(functor)
RESULT : QObjectBenchmark::signal_slot_benchmark():"functor":
     0.00004337 msecs per iteration (total: 4,337, iterations: 100000000)
     170.45074743 CPU cycles per iteration (total: 17,045,074,743, iterations: 100000000)
     280.06267229 instructions per iteration (total: 28,006,267,229, iterations: 100000000)
PASS   : QObjectBenchmark::cleanupTestCase()
Totals: 8 passed, 0 failed, 0 skipped, 0 blacklisted, 33228ms
********* Finished testing of QObjectBenchmark *********

Change-Id: I6f79fd68ae7a07d9b439ca047bf1f53c83751d45
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-03-03 09:55:56 +00:00
Milian Wolff
fe04aba46d Enable support for ref-cycles perf counter in QtTestLib.
The ref-cycles counter corresponds to the monotonic timestamp counter
that can be read using the RDTSC assembler instruction. Using it
instead of the default cycles counter is useful as it removes the
effect of dynamic frequency scaling on the measurement.

[ChangeLog][QtTest] The ref-cycles perf counter can now be used.

Change-Id: Id7d56576db362706c20f9a399e5acea35ee799f2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-03-03 09:55:22 +00:00
Marc Mutz
9c1d3bc253 QtOpenGL/plugins/platformsupport: use new QRegion::begin()/end() instead of rect()
Saves e.g. ~900b and ~2900b in text size in QtOpenGL and
XcbQpa libs, resp., on optimized GCC 5.3 Linux AMD64 builds.

Change-Id: Id904689164ca32df41118a23747c70048d8e6604
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-02 21:01:00 +00:00
Marc Mutz
9d3a415562 QtWidgets: use new QRegion::begin()/end() instead of rect()
Saves ~600b in text size on optimized GCC 5.3 Linux AMD64 builds.

Change-Id: Ib542a128982fc53638780945014d903f2cbee9c3
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-02 21:00:50 +00:00
Dan Cape
36ecf2c025 Fix QTextEdit/QQuickTextEdit undo bug - Part #2
If a user selected the text "foo" and typed "bar", upon pressing undo,
the text would change to "b". This is incorrect and does not match the
functionality of QLineEdit or the default behaviours of Windows/OSX/Ubuntu.
This was fixed by a change made to always merge two sequential inserts
if they are not part of the same block. Previously the selection delete
and the "b" were part of one edit block and "ar" was part of another.
With this change, the selection delete and "bar" are part of the same
edit block.

Unit test changes are part of a separate review (Part #1) since they
required changes in qtdeclarative.

[ChangeLog][QtGui][Important Behavior Changes] Fixed QTextEdit to match
undo functionality of QLineEdit to group two sequential inserts into one
undo action.

Task-number: QTBUG-38825
Change-Id: I76bf30e331e3526277c3e0ade58cf95b611fc117
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
2016-03-02 16:00:02 +00:00
Alex Trotsenko
6691df5336 QAbstractSocket::flush(): remove manual polymorphism
... by making a function in the private class virtual.

Change-Id: I45c25c6c59511a8e8821ca96b0cf28cbf1b2f267
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
2016-03-01 18:32:46 +00:00
Eskil Abrahamsen Blomfeldt
b4b829d928 Report correct font underline position on OS X
Text was sometimes drawn without a proper gap between the baseline
and underline.

[ChangeLog][Text][OS X] Fixed underline position.

Change-Id: I9b28d1ac39e18e8d98de92b354a1d635100853a9
Task-number: QTBUG-33708
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2016-03-01 12:15:00 +00:00
Eskil Abrahamsen Blomfeldt
1d5c29da59 Use correct underline thickness on OS X
While the calculated underline thickness would be approximately
correct for many fonts and sizes, it was sometimes incorrect,
e.g. for 18 pt Helvetica. Found while investigating QTBUG-33708.

Change-Id: Ic1d8f2d809c02235d8f15f0414536e04c2a7b844
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2016-03-01 12:14:56 +00:00
Eskil Abrahamsen Blomfeldt
ddef89b323 Use correct decoration for fallback font engines
The font engine itself specifies the line thickness, underline position
etc. so we need to pass in the correct one, not the multi engine
(which will just return whatever engine #0 prefers.)

Change-Id: I2b2b92e7881df8a8310aedbc6efa304c3210c095
Task-number: QTBUG-33708
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2016-03-01 12:14:51 +00:00
Liang Qi
d35d847be3 Merge "Merge remote-tracking branch 'origin/5.7' into dev" into refs/staging/dev 2016-03-01 12:06:48 +00:00
Marc Mutz
1a42124839 Q{File,Font,Color,Message}DialogOptions are no value classes
These classes are only held in QSharedPointer, so optimize for that:

1. Disable default ctor, copy ctor and assignment operator,
   destructor and swap for public users.
2. Add create() to return an instance in a shared pointer.
3. Allocate public and private classes in one memory block,
   use QSharedPointer::create() to also add the QSharedPointer
   control block to the same memory allocation.

As a consequence, this reduces the creation of a Q*DialogOptions
into a shared pointer by two memory allocations.

Add a macro to enable atomic updates to QtQuick and other users
outside QtBase.

[ChangeLog][QtGui]
[QFileDialogOptions/QFontDialogOptions/QMessageDialogOptions/QColorDialogOptions]
This class no longer has value semantics, but needs to be held
in QSharedPointer (as it always was). To copy an instance, use
the clone() method.

Change-Id: I4c81220e0a8286a310df1c224a30eca34824c4e6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
2016-03-01 07:41:46 +00:00
Liang Qi
24cd4a7190 Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: Ic7aaa06f4a14b1aed61faa1a6e7f527ee0eeb96b
2016-03-01 08:23:55 +01:00
Allan Sandfeld Jensen
1dd0c4bf1a SSSE3 optimized store of 24-bit formats
Using shuffle and align storing our quint24 format can be done much
faster. This in particular improves conversions to RGB888.

Change-Id: I179748706a33a43fd6f60f5c40287317418c8867
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
2016-02-29 19:39:27 +00:00
Laszlo Agocs
31a880f1f3 Remove lib/fonts symlinking from configure
The fonts directory is removed in 5.7. Avoid creating a broken
symlink.

Change-Id: I95d1970737f54810006c084436411fc95743f72d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-02-29 18:58:00 +00:00
Timur Pocheptsov
aeb169a488 Cocoa integration - avoid using dangling pointers
While re-parenting a widget on a mouse down, it's possible that NSWindow
lives longer than QCocoaWindow (because self.grabbingMouse == YES),
on mouse release event self.platformWindow is not nil yet, but is not a valid
pointer already. Bail out early before touching it.

Change-Id: Iea1025a82386d4b9dc21b3cbd3a5b248b2dd3620
Task-number: QTBUG-42059
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2016-02-29 14:36:08 +00:00
Liang Qi
a224dfc9d1 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	tests/auto/corelib/io/qprocess/tst_qprocess.cpp

Change-Id: Ib6955eb874b516b185b45d6c38cec646fbaa95f4
2016-02-29 12:34:31 +01:00
Gabriel de Dietrich
f253f4c331 Track target widget when wheel events are received
This issue is reproducible on OS X when using a Magic Mouse
or a combination of Magic Trackpad and regular mouse. In these
cases it's possible to start a scrolling gesture on one widget
and move the mouse cursor over another widget.

Although we send the wheel event phase information, we never
made any use of it. This means that a widget would start
scrolling even though it never received a ScrollBegin event.

In this patch, we make sure the scrolling cycle is respected
and that once a widget starts scrolling, it'll be recieving
all the wheel events until a ScrollEnd event reaches the
application.

For those input devices not supporting a proper phase cycle,
we introduce a new (undocumented) phase value, NoScrollPhase.
If the wheel event phase is NoScrollPhase, then we ignore
the current scroll widget and proceed as usual. This value
is the default for wheel events. It's up to the platform
plugin to set the proper phase value according to the data
received from the OS.

Finally, we fix a few of QWheelEvent constructors to properly
initialize the phase and source properties.

Task-number: QTBUG-50199
Change-Id: I3773729a9c757e2d2fcc5100dcd79f0ed26cb808
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
2016-02-29 08:19:51 +00:00
Marc Mutz
be84480785 QtTest: eradicate all Q_FOREACH loops
... by replacing them with C++11 ramge-for loops.

In one case, I took the liberty to remove a useless
if(isEmpty()) check around a for loop. Now that we
don't use Q_FOREACH anymore, we don't incur the copy
for empty containers anymore. Left the indention of
the loop level to avoid code churn.

Saves 1.8KiB in text size on optimized GCC 5.3 Linux
AMD64 builds.

Change-Id: I1b1fb34847f6a631f0d580fd5261c7f5fed8475c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-29 07:57:51 +00:00
Marc Mutz
a7885c9756 QVector: preserve capacity in clear()
This is what std::vector implementations usually do,
because it minimizes memory fragmentation and useless
allocations since no user will call clear() unless
she intends to append new data afterwards.

Fix calls to resize(0) that show how existing code
tried to work around the issue.

Adjust test. Port from QVERIFY(==) to QCOMPARE as a
drive-by.

[ChangeLog][QtCore][QVector] clear() now preserves
capacity. To shed capacity, call squeeze() or swap
with a default-constructed QVector object, see the
documentation for an example.

Change-Id: I9cebe611a97e027a89e821e64408a4741b31f1f6
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-02-29 07:57:47 +00:00
Marc Mutz
9132d1516a QRegion: use new begin()/end() instead of rect()
Saves ~100b in text size on optimized GCC 5.3 Linux AMD64 builds.

Change-Id: If2bbd2baac6f4ab66ad436028a8013ce0fa97a33
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 19:07:11 +00:00
Marc Mutz
79cbff60dd QtGui: use new QRegion::begin()/end() instead of rect()
Saves ~1100b in text size on optimized GCC 5.3 Linux AMD64 builds.

Change-Id: I928be44314dde06d5fdd2486a3417870bda64af4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 19:07:07 +00:00
Marc Mutz
d8f0a8a8a4 QRegion: use new begin()/end() in op<<(QDataStream)
Saves 132b in text size on optimized GCC 5.3 Linux AMD64 builds.

Change-Id: I435395c60802f446302ca6b2529d87c4cacb6304
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 19:06:49 +00:00
Marc Mutz
77164e4cc0 QRegion: make iterable
Virtually all code in Qt that inspects a QRegion does
so by calling rects(), which returns a QVector<QRect>.

But rects() has a problem: A QRegion that contains just
one rectangle internally is not represented by a QVector,
and the mere act of calling rects() makes QRegion create
one.

So, expose the fact that QRegion is a container of QRects
to users by providing iterators and begin()/end(), which
can be nothrow, since for the one-rectangle case, instead
of vectorize()ing the region, we just return pointers to
(and one past) the 'extent' rectangle.

As a consequence, the iterator type is just const QRect*,
but I think that whatever containers QRegion may use under
the hood in the future, it will be certainly one that is
layout-compatible with a C array.

No mutable iterators are provided, since QRegion maintains
a running bounding-rect, so a mutable iterator would have
to call into QRegion for every change, which doesn't make
sense.

[ChangeLog][QtGui][QRegion] Is now iterable as a container
of QRects: added {c,}{r,}{begin,end}().

Change-Id: I2fa565fac0c1d26e2c0937604b23763cd4e23604
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 19:06:44 +00:00
Marc Mutz
85c2a128ef QtWidgets: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops.

This is the simplest of the patch series: Q_FOREACH took a
copy, so we do, too. Except we don't, since we're just
catching the return value that comes out of the function
(RVO). We can't feed the rvalues into range-for, because
they are non-const and would thus detach.

Saves 2.2KiB in test size on optimized GCC 5.3 Linux AMD64
builds.

Change-Id: I914aa20fe65577b2e32ea7ea89d51a8d003a57ba
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 10:50:18 +00:00
Marc Mutz
e1c2bfa53b QtWidgets: eradicate Q_FOREACH loops [QVarLengthArray, std containers]
Q_FOREACH over a QVarLengthArray or std containers
is a particularly bad idea (because of the deep
copy that Q_FOREACH then performs).

Use C++11 range-for (without qAsConst(), because
neither QVLA nor std containers are CoW).

Saves 5.7KiB in text size on optimized GCC 5.3
Linux AMD64 builds.

Change-Id: I4c1fb0b488bb08726912528b559840a45c1397df
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-28 10:50:08 +00:00
Boris Pek
a17a7d37c2 Update QMAKE_LIB in win32-g++ mkspec
`ar' tool from latest binutils shows warning:
ar error: `u' modifier ignored since `D' is the default (see `U')

Warning message includes word "error" so QtCreator processes it as
error in UI.

`ar' command-line option `u' might be dropped safely because it is
unnecessary. Option `c' is added to suppress extra `ar' warnings.

Other build systems are also affected. For example, automake:
https://bugzilla.redhat.com/1155273

Change-Id: Ia378b720503d93b0c0c12ae7a5f38f4d7c32eee5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-02-27 08:09:15 +00:00
Friedemann Kleint
c3761bf6a7 tst_QDialog::snapToDefaultButton(): Do not check on exact cursor position unless hint is set.
Given the flakyness of cursor positioning, loosen the check to only verify
that the cursor is outside the window. The hint is only active on Windows
depending on a system setting.

Task-number: QTBUG-51516
Change-Id: I474d251cc41e68f182baf8dba84eaf38d914d7ee
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-02-26 19:17:19 +00:00
Marc Mutz
1d8030cc64 QtWidgets: prevent detach attempts from first()/etc. use [dialogs, kernel, util, widgets]
The algorithm used was:
- If possible, just declare the container const
- Otherwise, for first()/last(), use constFirst()/constLast()
  and for front()/back(), to not destroy the use of the STL
  API subset, use qAsConst()

Did some caching of function returns here and there, and
converted one 0 to nullptr as a drive-by.

Also saves almost 4KiB in text size on optimized GCC 4.9
Linux AMD64 builds.

Change-Id: I04b7bfd68dc85c22de247cb65a310e1cbbca1e8c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-02-26 18:56:43 +00:00
Friedemann Kleint
bc5917a10a Fix warnings about constructor initialization order in tst_QObject.
tst_qobject.cpp: In constructor 'DispatcherWatcher::DispatcherWatcher(QEventLoop&, int*, int*)':
tst_qobject.cpp:5871:10: warning: 'DispatcherWatcher::m_statusAboutToBlock' will be initialized after [-Wreorder]
tst_qobject.cpp:5870:10: warning:   'int* DispatcherWatcher::m_statusAwake' [-Wreorder]
tst_qobject.cpp:5815:5: warning:   when initialized here [-Wreorder]
tst_qobject.cpp:5870:10: warning: 'DispatcherWatcher::m_statusAwake' will be initialized after [-Wreorder]
tst_qobject.cpp:5869:17: warning:   'QEventLoop* DispatcherWatcher::m_eventLoop' [-Wreorder]

Amends change c5d4972577.

Task-number: QTBUG-18434
Task-number: QTBUG-32859
Task-number: QTBUG-36434
Change-Id: I03a9c872469334741a26b4dc1783a36d48f1556f
Reviewed-by: Paolo Angelelli <paolo.angelelli@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-02-26 17:37:32 +00:00