Commit Graph

7061 Commits

Author SHA1 Message Date
Marc Mutz
863debd720 Revert "Add expandingListItems property to QListView"
This reverts commit a4c25c0205.

The API is too limited in scope, and a good name is hard to find, as
evidenced in the API review discussion preceding Qt 5.9 beta.

This API will hopefully return as something like setItemAlignment().

[ChangeLog][QtWidgets][QListView] EDIT: REMOVE: Added expandingListItems property.

Conflicts:
	tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp

Change-Id: I397acd8a7a6c716e2d3c96eee45a276eb6d4f9dd
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru>
2017-03-03 08:34:19 +00:00
Olivier Goffart
1d9270ee42 Fix DPI of QWidget with parent on a different screen
If a floating QWidget has a parent on a different screen, its DPI was
still inherited from the parent instead of taken from the screen.

The only reason we did was in case there is a customDpi set.
(customDpi is a private thing that is only used in designer to change
the appearance of the previewed widget)

So instead of recursing into QWidget::metric for each ancestor, just
use a for loop to find if one parent has a customDpi. If no customDpi
is found, then return the DPI of the right screen.

Task-number: QTBUG-58959
Task-number: QTBUG-48242
Change-Id: Ie6e9e48cdd10234994c0919ba3aea9b0cdb52494
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-02 16:43:38 +00:00
Olivier Goffart
8387d87bdc QDialogButtonGroup: Fix removal of deleted buttons
As the destroyed() signal is emitted from ~QObject, it is not allowed
to use static_cast to a QAbstractButton on that pointer anymore.
And the qobject_cast will also fail which will keep a dangling pointer
in the hash.

Change-Id: If0d22fcc30cde87e771e70914c3afb04ea207289
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-03-02 10:42:55 +00:00
Liang Qi
71264bae08 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I84097f8e7b3b2128028bd7693c913d6968b82bfe
2017-03-02 09:04:38 +01:00
Eirik Aavitsland
c4c8886a86 ppm/pgm image formats: fix reading 16bit and limited range
The color values of ppm and pgm images can be either 8 or 16 bits.
They can also be scaled to a smaller max value, and they can be
expressed either binary or ascii. For some of these permutations, Qt's
image handler lacked implementation or would decode the wrong color
value. This commit fixes that.

Task-number: QTBUG-18262
Task-number: QTBUG-35990
Change-Id: I7cf11c2366244f3a9b31c1a565a81e2658bc6a51
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-02 07:59:50 +00:00
Marc Mutz
5e785c0b83 Add a string API symmetry test for mid/left/right
All good.

Change-Id: Iab278c24b4bd462d5e77af0c4f0fefb155d00551
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-01 13:40:12 +00:00
Thiago Macieira
fe2ab724de tst_utf8: Fix one of the overlong sequences to be what we meant
C0 to DF take one continuation byte; E0 to EF take two.

It's invalid UTF-8 anyway, but at least this is what the test row meant:
overlong sequence with 3 bytes of what should have been two.

This updates the comment to match the character that we were actually
testing.

Change-Id: I85a8bd6da2c44f52b4e3fffd14a75df2600487aa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-03-01 12:27:17 +00:00
Kai Koehne
58cf57492c Widgets: Replace LGPL21 with LGPL license header
Also use canonical contact url.

Change-Id: I59ed3d09d2fee877a577a00e7e1cb09782d26512
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-28 15:34:14 +00:00
Kai Koehne
a64c766a3d Network: Use canonical license headers
Replace outdated LGPL21 with LGPL license header.
Use GPL-EXCEPT for all autotests.
Also use canonical contact url.

Change-Id: I6e5cc8a4285569c4f862730a980f492b8a933a72
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2017-02-28 15:34:01 +00:00
Liang Qi
1a4f0deeb4 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I7d84cfed0b2a122d334b8a920e6e4f18472d2f11
2017-02-28 13:03:36 +01:00
Thiago Macieira
04b8db3d57 Fix parsing of day-of-week names that start with another name
Task-number: QTBUG-59159
Change-Id: I95c9e502ccc74af3bcf0fffd14a69e0cd27ce96b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-28 10:40:40 +00:00
Simon Hausmann
4a31eca4ce Make it possible to specify the RCC data version format
After commit d207738245 we unconditionally
write version two, but it seems useful to allow users to specify the
version explicitly.

Change-Id: I81d3de3d7f87318653f89bf10e3618becd8329d6
Task-number: QTBUG-58769
Reviewed-by: hjk <hjk@qt.io>
2017-02-28 08:44:50 +00:00
Marc Mutz
49c558eb0d QSizePolicy: inline toControlTypeFieldValue()
The implementation now uses the relaxed-constexpr
qCountTrailingZeroBits() function from QtAlgorithms, making the
QSizePolicy(Policy, Policy, ControlType) constructor constexpr on
C++14 compilers. The explicit check for DefaultType remains to keep
the constructor C++11-constexpr when called with just (Policy,
Policy).

Extend the constExpr tests a bit.

Change-Id: I59690f0921d9bdee08e3615d0d1f4a9b92870c32
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2017-02-27 23:09:27 +00:00
Robin Burchell
7a717aaf45 QImageWriter: Detect failure due to trying to write a QImage()
This is not a bug in QImageWriter, but caller code. We should be
explicit about what the problem was so it can be fixed.

[ChangeLog][QtGui][QImageWriter] Add QImageWriter::InvalidImageError to
communicate invalid attempts to write a bad QImage (for instance, a null
QImage).

Change-Id: I0333b8263f1da1c672bed17dab48bfd6cafe41a2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2017-02-27 18:03:33 +00:00
Edward Welbourne
1631384c27 tst_QWMatrix: use lambdas to duplicate messy code less
The cumbersome complex calls to QMatrix were surely easy to write
thanks to copy-and-paste; but this left the reader to either
laboriously check or guess that all the copies were the same (and
notice that there were two, in fact).  DRY.

Since QMatrix wants qreal data, change the float deg angle to a qreal
and work in qreal throughout.  Passing the angle to a function instead
of repeating it obviates the need for a local variable in the calling
code, to hold its value.

Change-Id: I6bb4adf438a893083ca19f27942502c1e5c518aa
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-27 17:45:28 +00:00
Ulf Hermann
44af54419e Properly use the "process" feature
Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in
qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess
headers, exclude the sources from compilation when switched off, guard
header inclusions in places where compilation without QProcess seems
supported, drop some unused includes, and fix some tests that were
apparently designed to work with QT_NO_PROCESS but failed to.

Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-27 15:44:46 +00:00
Laszlo Agocs
dfc338613e Make QPlatformSurface events work with QWindowContainer
Embeddeding a QWindow via QWidget::createWindowContainer() fails to
deliver the SurfaceAboutToBeDestroyed event. This breaks any OpenGL
or Vulkan based QWindow that releases resources upon this event, and
is particularly critical with Vulkan where the only way to do properly
ordered swapchain - surface cleanup is via this event.

In the non-embedded case close() eventually ends up in an explicit
destroy() in QWindow. In the embedded case destroy() only gets called
from ~QWindow. This then silently breaks since the subclass' reimplemented
event() virtual is not getting called anymore.

To remedy the problem, simply add an explicit destroy() to
QWindowContainer.

Task-number: QTBUG-55166
Change-Id: I1671e8f4d39f6c44e19eca7b9387f55fe3788294
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2017-02-27 12:38:08 +00:00
Laszlo Agocs
5bb4d06494 Add support for custom texture format in QOpenGLWidget
...in order to support sRGB framebuffers.

Add a --srgb option to the qopenglwidget example to allow testing.

[ChangeLog][QtWidgets][QOpenGLWidget] Added support for specifying
custom internal texture formats in QOpenGLWidget in order to make it
possible to have the widget backed by an sRGB-capable framebuffer.

Task-number: QTBUG-50987
Change-Id: I112e2f0ab0b1478c69e601031aa0bafaa87fa847
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2017-02-26 20:06:07 +00:00
Liang Qi
de49839df8 Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	mkspecs/features/moc.prf

Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
2017-02-24 20:01:42 +01:00
Thiago Macieira
07fffa6010 QDateTime: Fix clearing the ShortData flag in setMSecsSinceEpoch
Unlike setTimeSpec, this forgot to clear the bit when detaching. So it's
possible that some further use of the flags could incorrectly conclude
that the data was short and then proceed to corrupt the pointer.

The example from QTBUG-59061 caused this because toUTC() -> toTimeSpec()
calls setMSecsSinceEpoch which left the bit set; then addDays() calls
setDateTime(), which calls checkValidDateTime() and that corrupted the
pointer. This problem was more visible on 32-bit systems because no
QDateTime was short (except for default constructed ones), but it
can happen on 64-bit with sufficiently large dates.

Task-number: QTBUG-59061
Change-Id: Ibc5c715fda334a75bd2efffd14a562a375a4e69b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-24 16:17:03 +00:00
Timur Pocheptsov
09ca03e1aa QNAM - rename Redirect*s*Nnn to RedirectNnn
As discussed in API code-review.

Change-Id: Ib54cfd43d5bef8c7d99a7fb3b09a9d16dc1dc1dc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-23 20:24:17 +00:00
David Faure
9ffc9e306f QUrl::fromUserInput(with cwd) fix handling of files with trailing spaces
The call to trimmed() makes sense for URLs typed in a browser's location bar,
but its use in every code path made it impossible to open a file with a trailing
space in command-line tools that uses fromUserInput(cwd) to handle command-line
arguments, as recommended. For instance kde-open5 "file.txt " would fail.

Change-Id: Ie61182684521d91f077d3e76f95b7240965ab405
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 18:12:35 +00:00
David Faure
8cb9314971 tst_qurl: use temp dir and create our own files for testing
This allows to test specific filenames without polluting the current dir.

Change-Id: Ieb99019a2e37e30f294d85c5d80af1de1b919019
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 18:12:13 +00:00
David Faure
11790f41a7 tst_qurl: replace all QDir::currentPath() calls with local variable
Change-Id: I70e4547ba87292c29dfab59950aa1214be8015a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 18:12:06 +00:00
David Faure
90b48a70ff QTextFormatCollection: replace copy ctor and op= with clear()
operator=, which was only used for clearing, wasn't clearing the hash.
This led to a mismatch between the vector and the hash (given that the hash
points into the vector).

Spotted by interrupting kmail in gdb, and it was in this code
iterating over a 2000 entries hash (the first vector entries not matching
the hash, this code keep appending new entries for the same formats).

This fixes QTBUG-8862 again, the initial fix having been accidentally
reverted in 467b15a.

Change-Id: Ia34b3d002a0199e1930431a4bbdb2ec981ed4ffc
Task-number: QTBUG-8862
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-23 18:11:55 +00:00
Daniel Vrátil
30da659af5 Introduce QMetaType::PointerToGadget flag for pointers to gadgets
A Q_GADGET class can be used both as a value class and a pointer, but
right now QMetaType::IsGadget is only set for value types. This change
introduces PointerToGadget metatype flag which is set for pointers.

This allow for better handling of gadgets in code as well as
disambiguating between value types and pointers to value types.

Change-Id: Id3bd9e18a8eec7ca1cc6b1c25ed03cdc8c0a75a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-23 16:58:47 +00:00
Shawn Rutledge
8fd6cef372 add tst_QWidget::tabletTracking autotest
Ensure that tablet moves are delivered iff tabletTracking is true.

Task-number: QTBUG-26116
Change-Id: Iaa360e181f0c6484cfbde6fa5365f2f0dc77433a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2017-02-23 10:43:03 +00:00
Marc Mutz
62e15093ff Unexport QTimeZonePrivate
It's only used in the autotests, and it private API, so
downgrade from Q_CORE_EXPORT to Q_AUTOTEST_EXPORT.

Fix a use of QTimeZonePrivate functions unprotected by
QT_BUILD_INTERNAL in tst_qtimezone.cpp.

Change-Id: I70eaea06f8fcf2983aeafb6894c3a5d2a4b272a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-23 10:42:51 +00:00
Marc Mutz
b952bd3605 QSizePolicy: make (Policy,Policy) ctor constexpr
Unfortunately, that ctor also takes a ControlType argument (defaulted),
and calls the non-constexpr, non-inline function setControlType().

In order to make at least the two-arg version constexpr, I added
a use of the ternary operator to check for type == DefaultType,
making all calls of the ctor that use type == DefaultType
constexpr. For init'ing an aggregate type without ctor in the
ctor-init-list, I needed to require uniform initialization, too.

C++11-style constexpr cannot call void functions, so I needed
to extract the transformation part of setControlType() into a
new function that returns the result instead of storing it directly.

Saves a surprising 2K in QtWidgets text size on GCC 4.9, AMD64 Linux
stripped release builds.

Change-Id: Ib4adf5fd6e54d5345dbfe1c298554278faf13c58
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2017-02-23 05:44:51 +00:00
Lorenz Haas
2a3297c726 REGEXP for SQLite
Since SQLite does not define a regexp function by default, provide a Qt
based implementation which can be enabled using QSQLITE_ENABLE_REGEXP as
an connect option. This way statements like

SELECT * FROM table WHERE col REGEXP '^[a-d]';

work out of the box.

[ChangeLog][QtSql] Add QSQLITE_ENABLE_REGEXP connect option for
QSQLiteDriver. If set a Qt based regexp() implementation is provided
allowing to use REGEXP in SQL statements.

Task-number: QTBUG-18084
Change-Id: I7f0e926fe4c5d6baea509f75497f46a61ca86679
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Sebastian Sauer <sebastian.sauer@kdab.com>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-02-22 21:14:23 +00:00
Marc Mutz
494ee2aa8d QThreadPool: supersede cancel() with tryTake()
The cancel() function added in 5b11e43e for Qt 5.5 suffers from a
number of problems:

First, if runnable->autoDelete() is true, then the function suffers
from the ABA problem (see documentation written for trytake()).

Second, if runnable->autoDelete() is false, due to cancel() throwing
away crucial information instead of returning it, the caller cannot
know whether the runnable was canceled (and thus has to be deleted),
wasn't found or is currently executing (and thus mustn't be deleted),
or has finished executing (and can be used to extract the result).

Deprecate this dangerous API and replace it with the much more useful
Private::stealRunnable(), promoted to public API and renamed to
tryTake() for consistency with the rest of Qt.

Described the various caveats in the function's documentation.

[ChangeLog][QtCore][QThreadPool] The cancel() function suffers from
several subtle issues and has been replaced with a new tryTake()
function.

Change-Id: I93125935614087efa24b3e3969dd6718aeabaa4f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-22 16:37:07 +00:00
Ulf Hermann
46730ca610 Make the factoryloader test compile without library support
We define QT_STATICPLUGIN for the plugins in this case, so that they
define the factory functions needed to link them directly into the
test.

Change-Id: I0f2de7bf6bec5a6d53ec9ad92536817c1221b7d5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-02-22 15:53:13 +00:00
Marc Mutz
dbfde461ed tst_QProgressBar: add a case for INT_MIN/INT_MAX to setValueRepaint()
Convert the function to be data-driven, then add cases for ranges with
limits INT_MIN, INT_MAX and zero to check for overflows in the
painting code. Speed up the function by removing the per-iteration
qWait() call and rely solely on the existing QTRY_VERIFY() to do the
right thing.

Change-Id: I6d2a2c2b7637fca7ddb2a9adc5f6550f8255da14
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-22 13:55:51 +00:00
Marc Mutz
7c647edae9 QTypeInfo: don't treat enums and (extended) integral types as complex
We fully specialize QTypeInfo for most C++ built-in types,
but enums and extended integral types (like GCC's int128_t)
were not covered.

Now that we depend on <type_traits>, we can stop pessimizing
enums and extended integral types in QVector and QVLA by
defaulting QTypeInfo::isComplex to true for such types.

Fix a test that checked that enums were complex types. This should
have been a XFAIL test. Enums are not complex types.

Change-Id: Ibb0fb38cc83e980a428b5573d1db5666593418ae
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-22 09:21:57 +00:00
Oswald Buddenhagen
5e2367aaa5 use regular configure mechanism for openssl library references
don't attempt to hand-craft a library export any more. instead, use the
configure system's built-in mechanism, and refer to it via QMAKE_USE.
this also allows us to rely on transitive dependencies in the autotest.

as a side effect, this makes the openssl-linked feature imply the
openssl one.

Change-Id: I5dd209b63bc8fbbc62852f6ffc472d4452ea2e68
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-22 07:45:59 +00:00
Edward Welbourne
3cdf8debd1 Make sure to use C locale during time tests that assume it
Some format and parse tests for time and date-time depended on locale
but had test data for the C locale (so fail if the test-environment
has, e.g., LANG=de_DE@utf8).  So impose the C locale (until Qt 6).

The date-time test did *some* attempts at fixing for locale, but
failed to handle am/pm; and we do have "### Qt 6" comments in
Q(Date|Time)+::fromString indicating that we intend to switch these
methods to use the C locale by default (which shall fix this once and
for all).  So rip out the incomplete localization now and test we work
properly at least when the locale used *is* C.  Add a comment to the
matching QDate test to rip out its (presently adequate) matching code
once we do get to Qt 6 and make fromString() use the C locale.

QDateTimeParser uses systemLocale(), which is initialized the first
time it gets accessed; so we need to frob the locale *early*; doing so
in the test-class constructor is about as early as we conveniently
can; and seems to work (while doing it in individual tests does not).
(There is no point rolling back at the end; the QSystemLocale global
has been set up by then, so the roll-back would merely leave the
global out of sync with setlocale() and the environment.)

Task-number: QTBUG-58728
Change-Id: Ifa6778a80276050a099387a6dab15a1096be7561
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-20 08:48:46 +00:00
Liang Qi
bc4cd465dd Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	qmake/Makefile.unix

Change-Id: Ia18e391198222eef34ffa2df6f683e052058d032
2017-02-17 20:10:34 +01:00
David Faure
6c9b558153 QMimeDatabase: fix matching of filenames with different length when lowercase
AİİA.pdf takes 8 QChars, but after lowercasing it takes 10, so the code cannot
assume the length to be the same.

Task-number: QTBUG-58822
Change-Id: Id6fbb99f6afd08ee420099cd66372732d7598d9e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-17 18:52:50 +00:00
Jarkko Koivikko
b07f71a53f Widgets: Update micro focus in QLineEdit and friends
QLineEdit, QAbstractSpinBox and QComboBox did not notify micro focus
changes to the input context.

In particular, the updates were missed during pre-edit stage.

This change adds the missing bindings to QWidget::updateMicroFocus().

Change-Id: I9a7fff962f46dbabd8fb02836c206bace115793b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2017-02-17 17:09:50 +00:00
Eric Lemanissier
c5e687895d Adapt to the C++ SIC introduced by P0012: noexcept overloading
see 5a1b4832a2 for more detail

Task-number: QTBUG-58142
Change-Id: I51851ea9b4fe7b8eeadc452bc3dbb1ea00026d29
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-02-17 13:57:30 +00:00
Marc Mutz
0e3d6fe4f6 QVarLengthArray: fix appending an already-contained item
Like the lvalue QVector::append() overload, when we reallocate,
we need to take a copy of the function's argument because the
reference will get stale upon reallocation.

Add a test.

[ChangeLog][QtCore][QVarLengthArray] Fixed a bug involving
appending an item already in the container to the container
again.

Change-Id: I06eeed6cb383dd5924e47a302bb3d1666d04c8e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-17 07:35:31 +00:00
Thiago Macieira
d9a2dd8d3b QDir::mkpath: don't try to mkdir in automount filesystems
Automount filesystems like /home on many operating systems (QNX and
OpenIndiana, at least) don't like if you try to mkdir in them, even if
the file path already exists. OpenIndiana even gives you an ENOSYS
error.

So instead, let's try to mkdir our target, if we fail because of ENOENT,
we try to create the parent, then try again.

Task-number: QTBUG-58390
Change-Id: Ibe5b1b60c6ea47e19612fffd149cce81589b0acd
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-16 21:08:32 +00:00
Liang Qi
c577f6edaf Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	src/corelib/plugin/qlibrary_unix.cpp
	src/plugins/platforms/xcb/qxcbconnection.cpp
	tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp

Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
2017-02-16 21:51:11 +01:00
Marc Mutz
a5febadac5 QString(Ref): make toLatin1()/toLocal8Bit() null handling consistent
Systematic testing in tst_QStringApiSymmetry revealed a bug in
QStringRef::toLatin1(): a null input did not result in a null output,
but an empty one. This is fixed, for consistency with
QString::toLatin1(), and QString(Ref)::toUtf8(), which behaved
correctly already.

The same bug was found in QString(Ref)::toLocal8Bit(), which is
particularly hideous, as it's documented to fall back to toLatin1(),
which preserves null inputs. Fixed, too.

[ChangeLog][QtCore][QString] toLocal8Bit() now preserves nullness of
the input QString (outputs null QByteArray).

[ChangeLog][QtCore][QStringRef] toLocal8Bit() and toLatin1() now
preserve nullness of the input QStringRef (output null QByteArrays).

Change-Id: I7026211922c287e03d07e89edbad2987aa646e51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-15 20:12:36 +00:00
Timur Pocheptsov
b5995afc79 Fix http2 auto-test
After it started to fail (somehow it's only OpenSUSE 42.1) again and again
and after a quick re-evaluation it appears the logic testing SETTINGS|ACK
is incorrect. We (client side) start by sending the preface and then
continue to send our request(s). The other side (server) starts from sending its
SETTINGS frame. These settings must be ACKed, but apparently it can happen,
that server receives a requests and sends a reply before it receives SETTINGS|ACK,
resulting in replyFinished (replyFinishedWithError) signal and event loop stopping.
As a result - QVERIFY(serverGotSettingsACK) fails.

Task-number: QTBUG-58758
Change-Id: I8184cf459b2b88f70c646171e0115c184237fad1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-15 14:11:19 +00:00
Edward Welbourne
2aec5c9b34 Package transient zone setting in test to ensure restore on fail
tst_QDateTime::operator_insert_extract() was setting the time-zone and
taking care to restore it at the end of the test; however, if the test
were to fail, the restore would be skipped.  Package the zone-setting
and restore in a class instance, so that premature return can't bypass
the restore.

Change-Id: I3df63260da17e481ef4d0d107d9f0fdea3e147e7
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-15 13:48:37 +00:00
Marc Mutz
b4689401a5 tst_QThreadPool: don't deadlock when a cancel() test fails
We keep the runnables from finishing by having them block
on a QSemaphore::acquire() call inside run().

If we fail a test that precedes the call to sem.release()
further into the test, the early return will cause the
thread pool to be destroyed, which will then attempt to
wait for the runnables to finished, which, in turn wait
for the semaphore to be released.

-> dead lock

Fix by introducing a RAII object to release the semaphore
with a sufficiently large number to unblock all runnables.
That number will in some situations be too large, but that
does not matter.

Change-Id: I1ec7e29b37bc36309e93e6e30708cc7db3c9579c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 11:25:48 +00:00
Marc Mutz
410a14cc76 Wait for runnables to start up in tst_QThreadPool::cancel()
In order to get reproducible runs of the test, we need to
wait in the main thread until all runnables have started
executing. Otherwise, what the cancel() loop below actually
does will vary from run to run.

Change-Id: Ib912b0943e7bbd55c9480ae6fd4011ba20ac457e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-15 11:25:39 +00:00
Marc Mutz
8087ea67b1 tst_QThreadPool: simplify cancel()
Instead of allocating a statically-sized array on the heap,
use an automatic C array instead.

Replace some magic numbers with named constants.

Change-Id: I17d29a76a67c4a413453ac26a5dee8cd54a8a37d
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-15 11:25:30 +00:00
Marc Mutz
dcf74bdec8 Fix UB (data race) in tst_QThreadPool::cancel()
Manipulating a simple int from multiple threads is a data race,
thus undefined behavior.

Fix by using QAtomicInt and atomic operations instead.

Change-Id: I5418bc260da57fe353a71b8e5c7c1c97adbe7597
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-15 11:25:24 +00:00
Thiago Macieira
cab4d495b2 50 ms isn't enough for the CI, so increase to 100 ms
This should reduce the failure rate. We're still doing qSleep of the
same amount of time, but we now only fail if the slip is over 100 ms.

Task-number: QTBUG-58713
Change-Id: I536c32a88bff44dab37afffd14a1afdf0b2e522a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-15 08:09:57 +00:00
Timur Pocheptsov
5542e772d6 tst_qlocale::macDefaultLocale - remove flaky/incorrect test
currencySymbol == "$" does not mean negative currency values will be formatted
as "($value)". With all locales I have on my mac machines (10.11/10.12) the
result is different from what this test expects. Also, the results are very
different for different locales.  Apparently, we never saw this problem before
since in our CI "macs" we never have US Dollar/en_US selected in System Preferences.

Task-number: QTBUG-58784
Change-Id: Ic2c3a3172bf1e715e99092ddee8f461b216d995a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-15 07:43:26 +00:00
Marc Mutz
1cbf402ea6 tst_QMimeDatabase: increase timeout
The runUpdateMimeDatabase() call was timing out on the CI due to
running out of the default 30s timeout for QProcess::waitForFinished()
(on my machine, that call takes less than 0.5s, reliably...).

Increase to two minutes.

Change-Id: I61b2e060ea9c2508b853847ba7040ad499e0084c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-14 13:51:12 +00:00
Marc Mutz
6c4d75a485 tst_QSemaphore: avoid deadlock on test failures
When one of the QCOMPAREs in Consumer::run() fails, the consumer
returns early, leaving the producer deadlocked in a QSemaphore's
acquire() call. Change these to tryAcquire() with a large timeout,
so the producer, too, eventually leaves run().

Change-Id: I7421d43305decd4754e09c8e092363594d1be06b
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-14 13:30:16 +00:00
Friedemann Kleint
737383875e Blacklist tst_QTimer::remainingTime() on Windows and macOS
Task-number: QTBUG-58519
Change-Id: Ib03aa0bdeaa9ed0dc2f0d92aa11d07ffcdc2bc26
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-14 13:30:12 +00:00
Milla Pohjanheimo
c6792bcb95 Binary compatibility files for QtBase (5.8.0)
Added BC files for QtBase for Qt 5.8.0

Change-Id: I36d5453b8cfb5d34511a9b6196d4dc83d5c9f9f6
Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
2017-02-14 12:42:20 +00:00
Liang Qi
27432d40f2 Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: I2bd2e61bae1eab4fc74fa6accd741ed9ae1f0669
2017-02-14 11:33:02 +01:00
Marc Mutz
10ecbc4041 Blacklist tst_QWaitCondition::wakeOne() on Windows
This test was determined to be flaky on the CI.

Task-number: QTBUG-58741
Change-Id: I43196d3a27f726fb96b427f5071e726b571a0404
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-14 06:51:52 +00:00
Marc Mutz
f0ee4ed0a2 Long live QSemaphoreReleaser!
This is a simple RAII class that makes semaphore releasing
reliable in the face of exceptions and early returns.

This code originates from KDTools' KDSemaphoreReleaser[1], but
has been extensively reworked to support C++11 move semantics.

[1] https://docs.kdab.com/kdtools/2.3.0/class_k_d_semaphore_releaser.html

[ChangeLog][QtCore][QSemaphore] Added a new RAII class, QSemaphoreReleaser,
to reliably perform release() calls.

Change-Id: I6aff64d37cc0882b17c4419817bde60b542f34d9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-14 06:46:03 +00:00
Mikkel Krautz
9c765522d1 qsslsocket_mac: handle 'OrLater' SslProtocols in verifySessionProtocol()
The verifySessionProtocol() method in the SecureTransport backend did not
properly handle TlsV1_0OrLater, TlsV1_1OrLater and TlsV1_2OrLater.

This commit teaches verifySessionProtocol() about them.
It also adds TlsV1_0OrLater, TlsV1_1OrLater and TlsV1_2OrLater to the
protocolServerSide() test in tst_qsslsocket.

Change-Id: I394766c75dbea4d89bf3d6b9c3f3c89530ac0749
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-02-13 21:44:05 +00:00
Tor Arne Vestbø
09e7a994d1 Don't create platform window for QWindows when calling setVisible(false)
We can defer the creation until the window is shown.

Change-Id: I3d5b45ae59ee0925996cf12cd46dd574c8c6ef95
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-13 18:30:06 +00:00
Filipe Azevedo
9db8c171e7 Fix QLibrary::isLibrary on Apple platforms
Add proper support for 'so' and 'bundle' suffixes.  Qt wrongly assumes
.so libraries are not versioned on Apple platforms, which is
wrong. Also, the shared library .bundle which is what Apple recommends
instead of .so, are also versioned (not to be confound with the
different Core Foundation bundles, which are directory hierarchy).

For more info, see http://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm.
Especially the part that reads:

"Loadable modules, called bundles in Mac OS X, have the file type
MH_BUNDLE. Most Unix-based software ports usually produce bundles with a
.so extension, for the sake of consistency across platforms. Although
Apple recommends giving bundles a .bundle extension, it isn't
mandatory."

Task-number: QTBUG-50446
Change-Id: Iacd5136397a12d65d83821434f332eb602550b4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-12 18:25:42 +00:00
Erik Verbruggen
268afd8aef Extend QString equality tests with more long strings
Vectorized versions of ucstrncmp work on larger chunks of text
(typically 8 characters and an optional 4 more in some cases), so there
are now 4 extra sets of tests:
- strings of 1-65 characters, all different
- strings of 1-65 characters, all the same
- strings of 1-65 characters, all the same *except* the last character
- strings of 16 characters long, all the same except one, and that one
  is different for every string (i.e. first string differs in first
  char, second in second char, etc)

This should excercise both 1 or more iterations of the vectorized loop,
the detection logic inside the loop, and off-by-one cases.

The input is all ascii, so the ::compare() test will run them for both
QChar-QChar comparisson and for QChar-latin1 comparisson.

Change-Id: Ifaa7e019c63b581d4af5aef6dcfb3e7456c7d360
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-12 12:51:36 +00:00
Thiago Macieira
b1b53b7101 Revert "Add tests for QCollatorSortKey"
This reverts commit b0c1e07d64.
The unit tests it introduced trigger errors with the macOS and
Win32 implementations, which means the there's something seriously
wrong with either the API, our implementation or the tests.

Revert for now until this gets fixed. Blacklisting was also the
wrong tool to use. The tests should have used QEXPECT_FAIL.

Change-Id: Ida20c6bbe0c019835a22464535029585e8e1e367
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-12 08:15:48 +00:00
Marc Mutz
b0c1e07d64 Add tests for QCollatorSortKey
There weren't any, at all.

Testing on the CI showed that the implementation is broken on
macOS, and, to a lesser extent, on Windows, so blacklist the
failing tests until the implementation can be fixed. No need
to hold back testing the other implementations.

Task-number: QTBUG-58737
Change-Id: I9ae16ab778dbe2e95a6ca5e0bae00df4bad65cb2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-11 07:37:22 +00:00
Liang Qi
364b161122 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	src/widgets/widgets/qmainwindowlayout_p.h

Change-Id: Id406a67606b885052ed405b0fbc8eea7d9d03224
2017-02-10 22:35:04 +01:00
Marc Mutz
44d5fb33be Blacklist tst_QSemaphore::tryAcquireWithTimeout(0.2s) on Windows
This test was determined to be flaky on the CI, depite attempts
to stabilize it (b750a3786f).

Task-number: QTBUG-58745
Change-Id: I933199cd537002699906147d172bb797f1dc90c1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-02-10 14:15:16 +00:00
Olivier Goffart
0e20635c39 moc: error out when the Q_PLUGIN_METADATA file can't be opened
Task-number: QTBUG-56045
Change-Id: Ib058791036a2728dcd6215009a4ff206278bed14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-10 06:55:48 +00:00
Marc Mutz
0f2638c994 Blacklist tst_QElapsedTimer::elapsed() on Windows
This test was determined to be flaky on the CI.

Task-number: QTBUG-58713
Change-Id: Ie6e6a69b8ea625e3a3102c88d52f1f0fbec242aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-09 10:01:08 +00:00
Liang Qi
dd756011da Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
	configure.json
	mkspecs/win32-icc/qmake.conf

Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
2017-02-08 15:49:18 +01:00
Marc Mutz
626a4d89c2 QFormLayout: take the correct row in takeRow()
I didn't even try to understand what the old code was trying to do;
once you're told by a user that the code is wrong, you see that it is.

Fixed by just using the row as passed to takeRow() instead of trying
to do some storage-index calculations. The m_matrix indexing operator
does it all for us.

Added a test that checks that the expected field widget gets
returned. Fixed expected test data that was wrong, and just checking
that the implementation behaves as implemented, instead of as
documented.

Amends change 8fbae648db.

[ChangeLog][QtWidget][QFormLayout] The functions takeRow() and
removeRow(), new in 5.8.0, now take and remove the correct row.

Task-number: QTBUG-58693
Task-number: QTBUG-15990
Change-Id: I7185ccbc6c03e2579741cad5c0c821d3ed165474
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-08 11:01:31 +00:00
Marc Mutz
9e5e30fa13 QStringMatcher: fix setCaseSensitivity() on a non-QString-backed matcher
When a non-QString-backed mode (via the (QChar*, int) ctor) was added
for Qt 4.5, the author forgot to adjust the setCaseSensitivity()
function.  It still uses q_pattern instead of (p.uc, p.len) as the
pattern for which to create the skip-table. Since there is no
setPattern() overload for this mode, the correctness of the matcher is
not harmed by this, but its performance degrades to that of a linear
scan: the skip-table, being filled from an empty pattern, will be
all-zeros, sending bm_find() into the 'possible match' case at every
character.

Since matching is still correct, but slow, it's not possible to write
a test for this. I did, however, leave my attempts in the auto-test,
for when we add QStringView overloads of setPattern() which will then
be able to expose the bug.

Change-Id: I7b803e8624b0352a0a974900affbbfc0c260d93b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-02-07 16:31:00 +00:00
Samuel Gaist
8b1d9d308b Fix result handling in QDialog::done
The setData method of an item view would get an incorrect value of a
QDialog's result. This patch changes the order of functions called to
fix that.

[ChangeLog][QtWidgets][QDialog] Fixed a bug where accessing the result
of QDialog's result could yield an incorrect value in some situation
like using it as a delegate for item views.

Task-number: QTBUG-6018
Task-number: QTBUG-12156
Task-number: QTBUG-14430
Change-Id: I6ee4b6e8cacf6a806631c05c6c5dbcff925df65e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-02-07 09:09:42 +00:00
Friedemann Kleint
91120599ae QRasterPlatformPixmap::createPixmapForImage(): preserve DPR
Remove the line setting the DPR from the source; the image
is moved.

Task-number: QTBUG-58653
Task-number: QTBUG-58645
Change-Id: I2de94681459dba1d69dee06da44617fb9fa35bcc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-02-06 16:57:41 +00:00
Marc Mutz
c876bb1f13 QInputDialog: prevent crash in static get*() functions when parent gets deleted
As explained in

   https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0

creating dialogs on the stack is a bad idea if the
application or the dialog's parent window can be closed
by means other than user interaction (such as a timer or
an IPC call). Since we cannot know whether Qt is used to
build such an application, we must assume it is, create
the dialog on the heap, and monitor its lifetime with a
QPointer.

Instead of using manual resource management, add a
minimal implementation of QAutoPointer, and use that in
all static get*() functions.

Task-number: QTBUG-54693
Change-Id: I6157dca18608e02be1ea2c2defbc31641defc9d1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-02-06 14:41:46 +00:00
Aleksey Lysenko
f53ab9d736 Reset QFileDevicePrivate::cachedSize on file close
When a QFile object is reused, the atEnd() method may return incorrect
values. The reason for this is that QFileDevicePrivate::cachedSize is
not cleared. Setting cachedSize = 0 in the close() method fixes this issue.

Task-number: QTBUG-57698
Change-Id: I828a2cf844e98d581098f2c781fa47d2cd3275ce
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-06 07:36:24 +00:00
Thiago Macieira
239418a947 Use a precise timer in tst_QTimer::remainingTime
At 200 ms, the error on first firing could be 10 ms.

Task-number: QTBUG-58519
Change-Id: Ifaee7464122d402991b6fffd14a02a4ce782f11f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-02-05 18:19:51 +00:00
Friedemann Kleint
c0ff4fad73 Tests: Fix Clang warnings about inconsistent override
tst_qsortfilterproxymodel.cpp:3997:14: warning: 'data' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
tst_qsortfilterproxymodel.cpp:4004:9: warning: 'rowCount' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

accessiblewidgets.h:101:11: warning: 'interface_cast' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
accessiblewidgets.h:115:13: warning: 'textBeforeOffset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
accessiblewidgets.h:121:13: warning: 'textAtOffset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

Change-Id: I75ba00a0109ff25a2a22554980b8e541e661f806
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-02-05 10:54:36 +00:00
Friedemann Kleint
08d1706be3 Tests: Fix Clang warnings about various unused variables
tst_qpainter.cpp:400:26: warning: unused variable 'maskSource_data' [-Wunused-const-variable]
tst_qpainter.cpp:422:26: warning: unused variable 'maskResult_data' [-Wunused-const-variable]
tst_qfuture.cpp:1203:11: warning: unused variable 'resultCount' [-Wunused-const-variable]
tst_qvarlengtharray.cpp:33:11: warning: unused variable 'N' [-Wunused-const-variable]

Change-Id: Ic8891603089a877a5c69701c63c2c6fd20fa6a22
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-02-05 10:54:28 +00:00
Gatis Paeglis
6ecfab30d0 Remove references to QUrlOperator (Qt3) class
Change-Id: I2bb9fa77a8e260d5ba75541f66597a1c8904895f
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2017-02-04 06:52:15 +00:00
Thierry Bastian
b8dbde10a0 Fix data corruption when reading byte arrays from QSettings
On macOS, the code that read the plist is using
QByteArray::fromRawCFData. When we return the data directly
we need to detach the QByteArray so that it does not point
CFData's data that will get deallocated just after the call.

Task-number: QTBUG-58531
Change-Id: If829a304b986c99c8fc2aeeb992f2d539a4eef3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2017-02-03 15:37:58 +00:00
Friedemann Kleint
59ad4465b1 tst_uic: Update version regexp
The pattern did not match double-digit version numbers like 5.10.0.
Adapt it to better match the version number and use QRegularExpression.

Change-Id: I2e25b247213cee6853bfeb27871c839135e3970f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2017-02-03 12:01:55 +00:00
Eskil Abrahamsen Blomfeldt
3e238113f8 Accept error margin in QGlyphRun/QStaticText test for decorations
When calculating the width of a text for drawing decorations on top,
we use the effective advance of the whole text after it has been
through the shaper.

However, in the case of QStaticText and QGlyphRun, there is shortcut:
Since we only have the glyph indexes and position of each glyph,
we use the position + advance of the right-most glyph to find the
right-most edge of the decoration. For this, however, we use the
advance of the glyph *out of context* of the rest of the string,
because the whole idea is to avoid doing the shaping of the string
with every draw call. In some rare cases, the advance of the
right-most character, in the context of the string, is different
from the advance of the standalone glyph.

Now, one way of fixing this would be to store the width of the
text in QStaticText and QGlyphRun, but since it is a very rare
artifact which is barely visible, I have opted to just work around
it in the test instead, the workaround being to force integer
metrics so that we don't get the small 0.2 pixel error.

Task-number: QTBUG-55217
Change-Id: I8d16d52f2ef27275cabb7d3865aeeaa31617ba3d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-02-02 15:10:41 +00:00
Konstantin Ritt
89501f9a7b Adjust some tests to pass with latest HB-NG changes
Recent HB changed the way of handling ZWJ/ZWNJ to be more in par
with other engines.

Change-Id: I8abacd195e4b247c8fa6d91ef1086e74da0a1efb
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2017-02-02 15:10:37 +00:00
Eskil Abrahamsen Blomfeldt
db2054fb2f Fix tst_QFontMetrics::elidedMultiLengthF with some fonts
The QFontMetricsF version of the test should not truncate the
returned values, as the results may then be wrong.

Change-Id: I17f97f846bb723709e695e8866e437d6888d275b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-02 15:10:27 +00:00
Eskil Abrahamsen Blomfeldt
57fb8b11cd Fix tst_QTextScriptEngine::thaiWithZWJ() on OpenSUSE
OpenSUSE has a bitmap font called "Waree" while the test
is created for the TrueType font which is available on Ubuntu.
The style names are different, so we can use that to check
that we have the right one.

Change-Id: I808d0d1ecde9f10ed7730dc76ab3818490002ba9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-02 15:10:24 +00:00
David Faure
a9cb5e1ab6 modeltest: improve debugging
- QCOMPARE takes (actual, expected) rather than the other way around
- Added a qWarning with more details before a QVERIFY

Change-Id: I0a903a54db28ff2de1f684a2dd9abba3660ee916
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-02 12:13:06 +00:00
David Faure
61371f0321 tst_qurl: add test for fromUserInput(3 args) using "." as working dir
As used in recent qtdeclarative commits, so better make sure it keeps working.

Change-Id: I6d0ceda76201e3e7f75661cb6449e1ff32329126
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-02-02 12:12:58 +00:00
David Faure
c02d429d7f modeltest: code reformatting to the Qt coding style, using uncrustify
Change-Id: I39026fe0dbc0dacfada5ec2dc6dd81f20b05967c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-02-02 12:12:50 +00:00
Oswald Buddenhagen
dcd5cb9736 Merge remote-tracking branch 'gerrit/dev' into HEAD 2017-02-01 21:00:55 +01:00
Mitch Curtis
f299b565b5 Implement support for Scale directory key according to Icon Theme spec
Qt already supports high DPI icons using the “@nx” approach, where the
device pixel ratio that the image was designed for is in the file
name. However, our implementation of the freedekstop.org Icon Theme
specification did not support the Scale directory key:

https://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#directory_layout

This meant that users creating icons via QIcon::fromTheme() did not
get high DPI support. This patch fixes that.

[ChangeLog][QtGui][QIcon] Implemented support for Scale directory key
according to Icon Theme Spec. Icons created via QIcon::fromTheme()
now have high DPI support by specifying the Scale in the appropriate
entry of the relevant index.theme file.

Task-number: QTBUG-49820
Change-Id: If442fbc551034166d88defe607109de1c6ca1d28
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2017-02-01 13:58:01 +00:00
Thiago Macieira
14f0964344 QVariant: don't do fuzzy comparisons with NaN and infinities
There was a test that tested this, but was wrong.

[ChangeLog][QtCore][QVariant] Fixed a bug that caused wrong results for
comparisons of QVariants containing either NaN or infinite numbers.

Task-number: QTBUG-56073
Change-Id: I33dc971f005a4848bb8ffffd1475d29d00dd1b7f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-31 19:09:28 +00:00
Glen Mabey
3ab7016632 New qfloat16 class
This constitutes a fairly complete submission of an entirely new
floating point type which conforms to IEEE 754 as a 16-bit storage
class.  Conversion between qfloat16 and float is currently performed
through a sequence of lookup tables.  Global-level functions
qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and
qIsNull() each with a qfloat16 parameter have been included
for completeness.

[ChangeLog][QtCore] Added new qfloat16 class.

Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-31 14:21:42 +00:00
Glen Mabey
e5d303cb9f tst_qvariant: fix comparison ambiguity for QMetaEnum value
Under certain circumstances, VS2015 reported ambiguous options in using
the operator>(Enum,int) operator.  This change adds a static_cast<qint64>
to remove any ambiguity.  In the process of testing this change, a gap
in the existing logic was identified: the handling (just in the test
code) of large negative enum values.  Consequently, and additional
test case was added, and additional if-conditions were added to account
for that case.

Change-Id: Ife2c471ba4caa4b9a0107722042114e58145c4d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-31 14:21:02 +00:00
Erik Verbruggen
36f8816555 Fix 2 clang warnings
The first one was already suppressed for GCC, so also do that for clang:

/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: warning: format string is not a string literal (potentially insecure)
      [-Wformat-security]
    a.sprintf( zero );
               ^~~~
/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:1076:16: note: treat the string as an argument to avoid this
    a.sprintf( zero );
               ^
               "%s",

The second one could also occur with other compilers, so fix it in a
generic way.

/Users/erik/dev/qt5-dev/qtbase/tests/auto/corelib/tools/qstring/tst_qstring.cpp:6382:5: warning: ignoring return value of function declared with
      warn_unused_result attribute [-Wunused-result]
    string.repeated(3);
    ^~~~~~~~~~~~~~~ ~
2 warnings generated.

Change-Id: Id999179e795580a37b5be673ee54d6fa1a006dd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-31 09:27:56 +00:00
Thiago Macieira
e2c0d1ea2e Read the .ini file back in text mode
Because on Windows, the .ini files are saved with CRLF, but the files in
the Qt resource are just LF (.gitattributes makes them so).

Task-number: QTBUG-25446
Change-Id: I5eab0d9620bd1ba675b0a87c554f62cef0f98fcc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-31 06:03:39 +00:00
Liang Qi
246799d8a7 Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	examples/network/network-chat/peermanager.cpp
	src/widgets/util/qsystemtrayicon.cpp
	src/widgets/util/qsystemtrayicon_qpa.cpp
	src/widgets/util/qsystemtrayicon_win.cpp
	src/widgets/util/qsystemtrayicon_x11.cpp

Change-Id: I1c026df83818c0ccaf956980370e7522960627db
2017-01-30 12:46:20 +01:00
Marc Mutz
8b9b27bced QSizePolicy: add a transposed() method
In some situations, this allows for nicer code. It's also possible to
make this constexpr in C++11, whereas the mutable transpose() would
require C++14-style constexpr.

The new function should also be faster, since it just swaps the member
variables.

Because of constexpr-function limitations, the way the return value is
constructed needs to depend on the level of the compiler's C++11 support.
This is not the only class that requires uniform init to provide a fully
constexpr interface (QUuid and QBasicAtomic come to mind), so this should
probably be generalized across Qt at some point.

Added tests.

[ChangeLog][QtWidgets][QSizePolicy] Added transposed() method.

Change-Id: Ic1077a0d5a861e7c63bd1daeeb42b97c3a2f71ef
Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
2017-01-28 07:46:27 +00:00
Marc Mutz
ce3402b5ef QSizePolicy: add some constexpr
Also add a basic test for constexpr expressions involving QSizePolicy.

GCC < 4.8.0 has problems with initializing variant members in constexpr ctors:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922

Instead of revoking its Q_COMPILER_CONSTEXPR, which is a source-incompatible
change, simply note the fact so we can selectively provide constexpr for
QSizePolicy.

Change-Id: Iba8e5a7cdf847d73e8e2b6bb6211fb3c9846aa0a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-28 07:46:22 +00:00
Jake Petroules
9c9edaa6f5 Use qtConfig where appropriate
Change-Id: Ib865f074b930eab89c7552d0677bf2beb020f3ae
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-01-27 10:38:46 +00:00
Marc Mutz
2ccb7ecbca tests/auto/corelib/animation: clean up
- port from inefficient QLists to QVector
- mark types held in Qt containers (incl. QVariant) as Q_MOVABLE/PRIMITIVE_TYPE
- remove pointless user-defined copy special members which prevent the class
  from having nothrow move special members

Fixes errors reported by my local tree's static checks.

Change-Id: If3910484cea81a8e2c5ab737908c9443f75782c5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-26 16:44:10 +00:00
Marc Mutz
c2cecf08d5 QHostAddress: add missing op!=(SpecialAddress, QHostAddress)
The equality operator was supplied, but this one was missing.

[ChangeLog][QtNetwork][QHostAddress] Added op!=(SpecialAddress, QHostAddress).

Change-Id: Iad9c55fa0ee7a8e97d5e4ea4be0605b8b74649d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-26 16:44:02 +00:00
Eskil Abrahamsen Blomfeldt
8d752b5151 Accept all formatting characters as valid input
Amends 7896ae052a. The previous change
focused only on ZWJ and ZWNJ, but there are many other formatting characters
that we need to support and that may be rejected by the German keyboard-hack.
This opens up for all characters in the Other_Format category.

Task-number: QTBUG-58364
Change-Id: Idd967a9ae5b12060c851f6030b7e019508561696
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-26 10:59:49 +00:00
Marc Mutz
940d667eb4 Plug leaks in tests/auto/dbus
In tst_QDBusMetaObject::types(), hold a QMetaObject obtained from
QDBusMetaObject::createMetaObject() in a QScopedPointer instead of
leaking it. Use correct return value type.

This fixes the remaining errors in GCC 6.1 Linux ASan runs of
tests/auto/dbus.

Change-Id: I1df7f8e42d45f40ecf381fe7b684a8ab5ebee675
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-26 10:33:28 +00:00
Marc Mutz
e15cb86b3b Plug remaining memleaks in tests/auto/widgets/itemviews
... on Linux AMD64 builds.

Pass QObject parents to QObjects otherwise leaked.

Change-Id: Ia4f0ad2fdc4ef62a3d35a2cfca74965f79692da3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-26 10:32:51 +00:00
Marc Mutz
e4b19bfb94 Plug memleaks in tst_QHeaderView
The char* returned from QTest::toString() calls must be manually
delete[]ed.

Change-Id: Iad078e8741e3e97693b1a417693f414b3fb3ec09
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-26 10:32:45 +00:00
Marc Mutz
7e6e920633 Plug memleaks in tst_QTreeView
Forgot to delete QAIMs without parent.

Change-Id: I9c914e841123ee250fb977c45a84870463288d9b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-26 10:32:35 +00:00
Marc Mutz
9064d0b8a8 tst_QTreeWidget: plug memleaks
Taken QTreeWidgetItems need to be deleted, as do items
created without a parent, and widgets without parent.

Change-Id: I7ffa69903af9a1b92ba308f9f9416aec1d6d975f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-26 10:32:30 +00:00
Marc Mutz
1f814caca3 Plug memleaks in tst_QAbstractItemView
Styles need to be deleted manually...

Change-Id: Ic4193d22a57801127e994062cade7cb9ef6f34d8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-26 10:31:46 +00:00
Marc Mutz
a9603a4088 tst_qgraphicsview: use new QTest::addRow() more
... for calculated test data names.

That involved removing the leading ", " from test name literals
(folding it into the format string) and porting from some QString code
to QByteArray to make the result usable with addRow(), which does not
support %ls...

Change-Id: Icb2344778203f10939ae46b9e46872101f3878a9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-01-26 10:31:36 +00:00
Erik Verbruggen
fa15162700 Fix QString comparison on Aarch64
There was an off-by-one error in the while loop for aarch64: we start
counting at 0 for the first position, so the last valid input position
is "a+7", not 8.

This wasn't covered by the tests, nor was the SSE2 version, so now there
are also tests for both versions.

Change-Id: I7eb8c5708e6179f45ea56885b0e66e1a37969c1d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-26 09:34:46 +00:00
Allan Sandfeld Jensen
17e672a67e Use QImage::reinterpretAsFormat in QPixmap
Use the new QImage method instead of operating on private API.

At the same time the code is improved to ensure the QImage is detached.

Change-Id: Ia015c0bb18d7bc62da38397594730254843e5a0d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2017-01-26 09:14:27 +00:00
Liang Qi
398a7e736c Merge "Merge remote-tracking branch 'origin/5.8' into dev" into refs/staging/dev 2017-01-26 00:37:14 +00:00
Liang Qi
318b58562a Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	.qmake.conf
	mkspecs/common/msvc-desktop.conf
	mkspecs/common/msvc-version.conf
	mkspecs/common/winrt_winphone/qmake.conf
	mkspecs/features/mac/default_post.prf
	mkspecs/features/mac/sdk.prf
	mkspecs/features/qt.prf
	mkspecs/features/uikit/default_post.prf
	mkspecs/features/winrt/default_pre.prf
	mkspecs/winphone-arm-msvc2013/qmake.conf
	mkspecs/winphone-x86-msvc2013/qmake.conf
	mkspecs/winrt-arm-msvc2013/qmake.conf
	mkspecs/winrt-x64-msvc2013/qmake.conf
	mkspecs/winrt-x86-msvc2013/qmake.conf
	qmake/generators/win32/msvc_vcproj.cpp
	src/gui/kernel/qwindowsysteminterface.cpp
	src/network/kernel/qhostaddress.cpp
	src/plugins/platforms/mirclient/qmirclientplugin.cpp
	src/plugins/platforms/mirclient/qmirclientplugin.h
	src/widgets/util/qsystemtrayicon.cpp
	tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
	tools/configure/Makefile.mingw
	tools/configure/Makefile.win32

Done-with: Jake Petroules <jake.petroules@qt.io>
Done-with: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Change-Id: I4be3262d3994e11929d3b1ded2c3379783797dbe
2017-01-25 20:06:06 +01:00
Allan Sandfeld Jensen
f823af43f2 QVariant of nullptr should always be null
Implements isNull for QVariants of a nullptr so they always return
true to isNull(), instead of depending on how they were constructed.

Task-number: QTBUG-58296
Change-Id: Ibddec795cdadedef7e17d22c265c29e752d8f99f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-25 17:05:18 +00:00
Allan Sandfeld Jensen
374a173d14 Improve QTest::qWait() precision and switch to QDeadlineTimer
Do not wait up to the timeout ms after already having waited several
times. At the same time upgrade to using the QDeadlineTimer which
is designed for this purpose.

Change-Id: Iaf5e4f4655605d5143ce91040c6eb6706752e504
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-25 16:40:57 +00:00
Friedemann Kleint
a8a74fe81a Stabilize tst_QPropertyAnimation::noStartValue()
Remove the qWait() and introduce a QTRY_COMPARE()
checking for the end value first.

Task-number: QTBUG-58402
Change-Id: I2d3758178de5f67881008f28c406076ad27c4a90
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-01-25 11:36:41 +00:00
Jesus Fernandez
ad5eb297e1 Add QHostInfo::lookupHost overload with modern connect syntax
Task-number: QTBUG-56424
Change-Id: I49053ac2859e6c6c07e4a704b8b5f0d6a2d0b8a4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-01-24 20:54:07 +00:00
Oleg Yadrov
59780d132a Cocoa: fix crash regression in qt_mac_create_nsimage()
The regression was introduced in d8857f21ac. The original change was
meant to fix support for SVG icons, but failed to take into account
a valid QIcon with no sizes, but which is also unable to create
a pixmap for the requested size.

Task-number: QTBUG-58344
Change-Id: I7ac1dbfaf6e3dab8581fe4b33c814e2517fcdba8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2017-01-23 23:34:44 +00:00
Jake Petroules
4b507e8257 Add conversion functions for QTimeZone and CFTimeZone/NSTimeZone
Change-Id: I3a2e18d69577296bf612e13e40414bce1daa6a71
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-23 21:55:22 +00:00
Friedemann Kleint
45948967bd tst_QSocks5SocketEngine: Refactor tests
Rewrite tcpSocketNonBlockingTest() and downloadBigFile() to use lambdas for
the slots. This allows for removing the related member variables and slots
of the test class and ensures no leaks of sockets or inconsistent values.
Add an error handler printing the error message to the flaky downloadBigFile()
test.

Change-Id: Ieb64063c41e045a1a50a6d074bef01753ee319ef
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-01-23 12:22:54 +00:00
Julian Thijssen
7dc88b6890 Add support for OpenGL 3.2+ core profile contexts in QPainter
This change allows painting via QPainter onto a QOpenGLWindow, QOpenGLWidget
or QOpenGLFramebufferObject when an core profile context is in use. This is
important on macOS in particular, where compatibility profiles are not
available, and so the only way to use modern OpenGL is via a core profile
context.

Added core profile compatible shaders with moder GLSL keywords.

The paint engine binds a VAO and two VBOs from now on, whenever VAOs are
supported. Note that this changes behavior also for OpenGL 2.x context that
have VAO support via extensions.

The Lancelot test suite gains support for core profile contexts. This can
be triggered via -coreglbuffer in place of -glbuffer when manually inspecting
via 'lance', while tst_lancelot will automatically run core context-based tests
whenever supported.

Task-number: QTBUG-33535
Change-Id: I6323a7ea2aaa9e111651ebbffd3e40259c8e7a9c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-01-23 11:34:05 +00:00
Friedemann Kleint
578154c47d tst_QPauseAnimation: Use QTRY_COMPARE for checking the stopped state
Use QTRY_COMPARE with a timeout to check for the stopped state
unless BAD_TIMER_RESOLUTION is defined.
This speeds up the test by 1s and prints diagnostic information
should an interval be too short (as seems to be the case on macOS,
currently).

Change-Id: I8f884cd66ad33314124d3130d9f49606e6dfe9f3
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
2017-01-20 18:03:34 +00:00
Timur Pocheptsov
83f4f9b401 Add HTTP strict tranport security support to QNAM
HTTP Strict Transport Security (HSTS) is a web security policy that
allows a web server to declare that user agents should only interact
with it using secure HTTPS connections. HSTS is described by RFC6797.

This patch introduces a new API in Network Access Manager to enable
this policy or disable it (default - STS is disabled).

We also implement QHstsCache which caches known HTTS hosts, does
host name lookup and domain name matching; QHstsHeaderParser to
parse HSTS headers with HSTS policies.

A new autotest added to test the caching, host name matching
and headers parsing.

[ChangeLog][QtNetwork] Added HTTP Strict Transport Security to QNAM

Task-number: QTPM-238
Change-Id: Iabb5920344bf204a0d3036284f0d60675c29315c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-01-20 08:41:50 +00:00
Sebastian Lösch
da0241a2e7 Make variant selection possible if base is missing
[ChangeLog][QtCore][QFileSelector] Removed the requirement for an unused
default base file in case you want to load only a variant.

When the base file (e.g. /image.jpg) was missing, no selectors were
considered and it was not possible to load variants of this file (e.g.
/+android/image.jpg, /+android/+tablet/image.jpg) without specifying the
directory as well.

As a work around, one previously had to place a default file in
the base location, which is undesirable in some cases because:
1. The extra file consumes unnecessary space.
2. It is impossible to encapsulate platform-specific implementation
   details by hiding files in a subdirectory.

Task-number: QTBUG-51230
Change-Id: I4c7f9ec952bff6e5b7738d8cabe3c762c208a38e
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2017-01-20 05:25:19 +00:00
Marc Mutz
3af5cab054 Long live QStaticByteArrayMatcher!
This is a version of QByteArrayMatcher that calculates the
Boyer-Moore skip table at compile-time instead of at run-time,
making this class more generally applicable than QByteArray-
Matcher itself, at least for statically-known strings.

The compile-time part requires C++14 constexpr support, but
the class should compile and work even in C++98 mode, just
with runtime initialization of the skip-table.

While touching tst_qbytearraymatcher, clean up the static
global QByteArrayMatchers there and add tests with needles
longer than 255 characters for QByteArrayMatcher, too.

[ChangeLog][QtCore] Added QStaticByteArrayMatcher.

Change-Id: I0662f262ab19b79ae4096f3ab384d5b3ada72347
Reviewed-by: David Faure <david.faure@kdab.com>
2017-01-19 21:37:46 +00:00
Dmitry Shachnev
287f548d4c Make shortcuts work for platform menu bars
When a platform menu bar is used, the QMenuBar is hidden, so shortcuts
for QActions attached only to it do not work.

Extend the macOS-specific code to treat such menubars as visible to
other platforms, to make the shortcuts work.

The exception is made for internal QMenuBar shortcuts, which are
forwarded to the platform menu. A follow-up change will add support
for this to QDBusPlatformMenu. The updateGeometries() method is called
for platform menu bars too to make sure the internal shortcuts are
registered even if the global menu is in use.

Add two cases to the tst_QMenuBar::activatedCount() test to test
both native and non-native menu bars when possible (it now passes with
native menu bars too).

Change-Id: I2d7128512719ac199cd3f8f7ba28333d04d84ed4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2017-01-19 08:41:55 +00:00
Timur Pocheptsov
231259c3d5 Add a user-controlled auto-redirect policy
With this new policy, after emitting 'redirected', QNetworkReplyHttpImpl
waits for client code to decide if QNAM should follow this redirect or
not. The client can either allow this redirect by emitting 'redirectAllowed'
or abort the reply.

Task-number: QTPM-236
Change-Id: Ia04619f6bd1f0caa477833ae859b24033027b2e1
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-01-19 04:34:03 +00:00
Friedemann Kleint
eba886c32f tst_qaccessibility.cpp: Fix warnings about assignment used as truth value
tst_qaccessibility.cpp: In member function 'void tst_QAccessibility::treeTest()':
tst_qaccessibility.cpp:3005:75: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
tst_qaccessibility.cpp:3008:75: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
tst_qaccessibility.cpp: In member function 'void tst_QAccessibility::tableTest()':
tst_qaccessibility.cpp:3133:75: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

Change-Id: I175af3215258c70da8284907f5ddfe95abf41029
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2017-01-18 14:21:00 +00:00
Allan Sandfeld Jensen
f4a098c635 Introduce QImage::reinterpretAsFormat
QImage::reinterpretAsFormat can be used to change the format of an image
without converting the data, to correct wrong formats or narrow the
format to an opaque one if found to be opaque.

[ChangeLog][QtGui][QImage] A new method reinterpretAsFormat is has been
added to change the format of a QImage without converting the data.

Change-Id: I5e15bc5a1c474a35d3921b06299008ab2effd945
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2017-01-18 13:10:52 +00:00
Maurice Kalinowski
d3eec16862 Remove support for WinRT 8.1 and Windows Phone 8.1
[ChangeLog][QtBase][General] Removed support for WinRT/Windows Phone 8.1.

Task-number: QTBUG-57288
Change-Id: Ifd6d6780cbbdb710d99556ba3d2fb2e514d4f789
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-01-18 12:38:56 +00:00
Mikkel Krautz
19a1a0871d QSslDiffieHellmanParameters: simplify defaultParameters() construction
This commit simplifies defaultParameters() to simply construct an empty
QSslDiffieHellmanParameters and assigning the DER-form of the DH parameters
to QSslDiffieHellmanParametersPrivate's derData field.

This creates a valid QSslDiffieHellmanParameters instance, but skips any
potentially expensive verification steps.

The previous implementation of defaultParameters() would use the public
fromEncoded() method to construct an instance of the default parameters.
This triggers a verification of the passed-in data, which can be expensive.

To ensure our defaultParameters() QSslDiffieHellmanParameters instance does
pass verification, this commit adds an autotest to verify that.

Fixes QTBUG-57815.

Change-Id: I6b1d9dbbfde526b232c319195ddbad42326be27c
Task-number: QTBUG-57815
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-01-18 11:32:02 +00:00
Timur Pocheptsov
cebf1fea4a Add redirects policy to QNetworkAccessManager
This patch makes it possible to enable/disable redirects on QNAM
level (before it was per-request only). This policy would be applied
to all subsequent requests* created by QNAM.

The policies we support at the moment:
a. Manual - that's what we always had - it's up to a user to handle
   redirects.
b. NoLessSafeRedirectsPolicy - we allow http->http, http->https and
   https->https redirects, but no protocol 'downgrade' (no
   https->http redirects).
c. SameOriginPolicy - we check that protocol/host/port are
   the same.

Updated tst_qnetworkreply.

*We previously were enabling redirect for each request, by
 setting FollowRedirectsAttribute on QNetworkRequest object.
 For backward compatibility this attribute has a higher priority
 (if set) than QNAM's policy (and it will work as NoLessSafeRedirectsPolicy).

[ChangeLog][QtNetwork] Added redirects policy to QNAM

Task-number: QTPM-239
Task-number: QTPM-237
Change-Id: I493d1728254b71b61b5504937e8e01dca5953527
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-01-17 18:51:32 +00:00
Aleksei Ilin
0243863382 Fix access incorrect index in QListView with batch layout
The size of flowPositions is larger by one than the number
of rows in the model so the last correct row number is
flowPositions.count()-2, not flowPositions.count()-1.

Change-Id: Idf8bbd155151d553947d5d299dd01ffaff0c95fa
Task-number: QTBUG-47694
Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru>
Reviewed-by: David Faure <david.faure@kdab.com>
2017-01-17 14:00:31 +00:00
Sebastian Lösch
14bff46df4 Introduce QNetworkAccessManager::clearConnectionCache()
Sometimes it is desirable to use a new connection but keep already
entered user credentials for usability reasons. This is now possible by
clearing the connection cache (but keeping the authentication cache).

Change-Id: I2f5f64836ce19f81c8525701783a3da823dd468e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2017-01-16 11:04:46 +00:00
Marc Mutz
4baf08653c QHostAddress: add missing docs
qHash(QHostAddress) was added in Qt 5.0 (at least the version with uint seed = 0).

op==(QHostAddress::SpecialAddress, QHostAddress) was there since QHostAddress was
added before public history. Since QHostAddress does not have a \since, the I did
not supply one for op==, either.

Since the equality operator did not have unit-tests, added one.

Change-Id: I954a0df02464338f08a12ca58d4cc0ceb013e67a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-15 08:07:22 +00:00
Marc Mutz
610c7da075 Plug memleaks in tst_QStackedLayout
QLayout::replaceWidget() doesn't delete the affected item, but returns it.

Change-Id: Ibda96e4bf2432ad13ed2908c7d37547f46e29a37
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-01-14 18:17:47 +00:00
Thiago Macieira
5a1b4832a2 Adapt to the C++ SIC introduced by P0021: noexcept overloading
C++17 adopts P0021R1[1], which makes noexcept be part of the function
pointer's type and thus be overloadable. It contains some provisions for
allowing a noexcept function pointer to cast implicitly to a non-
noexcept function pointer, but that fails in the presence of templates
and additional overloads that could match the type in question.

Fortunately, the paper proposed a test macro, so we can change our
sources now and be compatible with both C++14 and C++17 rules.

This first failed with Clang 4.0 trunk. This source incompatibility is
not our fault, it's the language's doing.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html

Task-number: QTBUG-58054
Change-Id: I2bc52f3c7a574209b213fffd14988cf0b875be63
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2017-01-14 03:24:30 +00:00
Giuseppe D'Angelo
6255cb893d Remove qtypetraits.h's contents altogether
So that QFlags can use an (un)signed int matching the
underlying type as identified by the compiler and not by us.

Requires fixing a few warnings about sign conversion due to
QFlags misusages in qtbase that were either plain wrong, or
were relying on the enum being backed by an (un)signed int
when it wasn't.

Keep qtypetraits.h in the source tree in order to prevent
source breaks if some downstream #includes it (note however
that it did not contain any public API).

Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-12 22:16:06 +00:00
Alexander Volkov
a4c25c0205 Add expandingListItems property to QListView
This property allows to change the default behavior in
which list items occupy the entire width of the column.
Setting it to false will reduce their widths to the
minimum values, thus allowing to have intermediate free
space. Then the user will be able to begin selections
by mouse from this space.

[ChangeLog][QtWidgets][QListView] Added expandingListItems property.

Change-Id: I6bd1b147fd0335324310a165104c36f6b0d6ac9f
Task-number: QTBUG-56606
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2017-01-12 17:54:52 +00:00
Edward Welbourne
8f469e4a19 Remove two unused static methods of QDateTimePrivate
... along with the two matching unused methods of QDateTime's test.

Change-Id: Id11a4b1b0132587f0df451d49c0043e9425d87ad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-12 16:42:21 +00:00
Jake Petroules
2b928ef6f9 Provide sensible defaults for QCoreApplication::applicationVersion
[ChangeLog][QtCore] QCoreApplication::applicationVersion now defaults to
an appropriate platform-specific value. On Windows, it defaults to the
PRODUCTVERSION parameter of the VERSIONINFO resource for classic desktop
apps, and the version attribute of the application package manifest for
Univeral Windows Platform apps. On Apple Platforms (macOS, iOS, tvOS,
watchOS), it defaults to the CFBundleVersion property of the information
property list (Info.plist) file. On Android, it defaults to the
android:versionName attribute of the AndroidManifest.xml manifest
element. On other platforms, the default remains an empty string.

Task-number: QTBUG-57715
Change-Id: I26f83dd00737e06f4321cf962aa5fab8398104ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-12 02:13:21 +00:00
David Faure
2bb01172a7 QFont: fix fromString(toString()) when application font has styleName
The style name needs to be cleared if not present in the string,
otherwise the style name from qApp->font() (which propagates to
any default-constructed QFont) remains.

Change-Id: I9b6522a39a38526cced8a11ed02ae32582026480
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
2017-01-11 15:15:39 +00:00
David Faure
62882ad2fe tst_qfont: clear style name in test font
The test failed if qApp->font() had a styleName() set,
when testing old serialization formats which didn't serialize it.

Change-Id: If0236d354be144b3a990e074a22f796fffb1ed18
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
2017-01-11 15:15:36 +00:00
David Faure
f99589a515 modeltest: use QCOMPARE where possible
QVERIFY(a==b) is less useful than QCOMPARE(a, b) in case of an error.

Change-Id: Ibd294e7a1e9b55a9780551869c8477f6e41355ac
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-01-11 14:27:13 +00:00
Edward Welbourne
4b4bd6ab98 Simplify fileTimeToQDateTime() by having it return a UTC time
This avoids so many complications.  The prior code, using
SystemTimeToTzSpecificLocalTime(), lead to unhelpful results when the
QDateTime() implementation used MS-POSIX's defective mktime().
Although SystemTimeToTzSpecificLocalTime() is actually more correct,
we were getting inconsistent results by mixing the two: and
eliminating the use of mktime() turns out to be decidedly tricky.  So,
to avoid inconsistency, stick with a UTC time (which is what FILETIME
is defined as).  Change QFileInfo's methods to explicitly convert
.toLocalTime() where appropriate and document that these methods do
indeed return local time (as we conjecture has been taken for granted
by callers).

Also added a regression test for the reported case of this going
wrong.  A time-stamp from before Russia's (permanent, not DST) change
of TZ could end up inconsistently handled between file-system
meta-data and raw date-time APIs, due to cross-talk between different
MS-Win time APIs.

[ChangeLog][QtCore][QFileInfo] Made sure that all file lifecycle times
are in local time. This was probably true before, but is now explicit.

Task-number: QTBUG-48306
Change-Id: Ic0b99d25c4168f623d31967bc60665c0c4f38a14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-11 11:53:27 +00:00
Timur Pocheptsov
1636f3bc92 HTTP/2 - fix handling of GOAWAY frame
- Fix the case when we erroneously handled stream ID == 0 in a GOAWAY frame as
an invalid stream ID.
- _q_receivedReply: convert do{}while() loop into to while(){} to prevent
it from handling any frames after GOAWAY frame received and all active frame
finished.
- sendRequest - if we received GOAWAY, also clear spdyRequests in the connection
channel, otherwise it keeps re-trying to send requests!
- Http network connection channel never resets a protocolHandler in _q_encrypted/
_q_connected, which is BAD for HTTP/2, since HTTP/2 has unique per-connection
compression context and must be reset - now we recreate the protocol handler in
_q_encrypted or _q_connected (https/http).
- Update autotest.

Task-number: QTBUG-57600
Change-Id: Ib864ce52287bab23334ff43a83ba4b0b7cb52c60
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-01-11 10:39:43 +00:00
Tor Arne Vestbø
6f504a1cdd Widgets: report focus object change to QtGui before sending widget events
Updating the focus child means the focus object of the window has changed.
We need to report this to QtGui immediately so that it can e.g. inform the
input context of the new focus object, before widgets reacting to the focus
events start calling update() on the input method.

Change-Id: Ie3f7b835591e71519e3f384c2abdad53242c9736
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-01-10 23:24:57 +00:00
Marc Mutz
f480196f1b tst_utf8: remove duplicate nonCharacters() data
The population of data rows was factored into a separate file, qutf8data.cpp, in
commit e20c4730. Merge commit 9bd03235 failed to track a conflicting change into
the new file, and brought the code back into the tst_utf8.cpp, where it has been
duplicating the utf8data data ever since.

Change-Id: I4282685b882448f927289468bd7ab340a21ea0b3
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-10 18:39:31 +00:00
Jason Erb
ae42bf0f9b Fixed Chinese language selection on iOS
For language "Traditional Chinese" on iOS with region "US",
the logic was formerly to attempt a match on country/language/script (fail),
followed by country/language (which would result in script defaulting to
"Simplified"). Now, the logic is to try language/script first if script is
specified. Failing that, language/country will be attempted.

Task-number: QTBUG-39639
Change-Id: I75a774b1e66686e95167ff221458a97a7ea2660d
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jason Erb <jason.erb@sparist.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-10 17:35:35 +00:00