Commit Graph

6551 Commits

Author SHA1 Message Date
Marc Mutz
e0e4269e28 tst_QAbstractSlider: fix strict-aliasing warnings
GCC warned:

  tst_qabstractslider.cpp:858:89: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     Qt::Orientation orientation = *reinterpret_cast<Qt::Orientation*>(&sliderOrientation);
                                                                                         ^
  tst_qabstractslider.cpp:867:72: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     orientation = *reinterpret_cast<Qt::Orientation*>(&wheelOrientation);
                                                                        ^

The solution, of course, would be to use a static_cast here, but
why go via int in the first place? Qt::Orientation can perfectly
well be used in QFETCH, as proven by tst_qmainwindow, among other
things.

Change-Id: I97916a50405e16d114837bc52580ce6666d74b17
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-09-30 10:09:58 +00:00
Eskil Abrahamsen Blomfeldt
462f6029ed Fix crash when doing many text layouts with superscript/subscript
After e109b8a0f3, it is possible
that the cache will be flushed as a result of inserting a new
font rather than just when the timer event triggers. When doing
superscript and subscript text layouts, we would first get
a regular font engine, then a scaled one, and then reference
the regular font engine *after* getting the scaled one. If the
regular font engine was deleted as a result of inserting the scaled
one, we would get a dangling pointer and crash.

The situation was improved by 49926bb9ef.
You would now to switch between 256 different fonts in the layout
in order to trigger it. The test in the commit will trigger the
crash even with this change.

[ChangeLog][Qt Gui][Text] Fixed a crash that could happen if you
were doing many different text layouts with different fonts
and superscript or subscript alignment.

Task-number: QTBUG-53911
Change-Id: Ia33108252e030eff25924ef1b7c10b9d59b5bc8c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-09-29 12:43:19 +00:00
Marc Mutz
da2c73ad2b Plug memleaks in tst_QWidget
We need to delete the style returned from QStyleFactory::create()
ourselves, so put them into a QScopedPointer.

The alternative would have been to create this once, as a member
of tst_QWidget, but this is the minimal approach that ensures
behavior just as the old code, but without the leak.

Change-Id: I527f1031c57be6f05942f4acc057e7dae1af2571
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-28 04:56:48 +00:00
Marc Mutz
5571d2bf62 tst_QApplication: Fix UBs (invalid cast) in focusMouseClick()
Found by UBSan:

  tst_qapplication.cpp:1754:48: runtime error: member access within address 0x7ffda11f2220 which does not point to an object of type 'SpontaneousEvent'
  0x7ffda11f2220: note: object is of type 'QMouseEvent'

The code attempted to model the layout of a QEvent with another class
that allows public access to the memory location that (hopefully)
corresponds to QEvent::spont, gaining access by casting a QEvent
object to that specifically-crafted class.

Fix by the using the existing QSpontaneKeyEvent::setSpontaneous()
call, which, despite its name, works for all QEvent subclasses, and
which has already been fixed to not invoke UB (in bc087db).

Change-Id: I7db8b8a8a823f7d61ab17375142d19dc3874fea5
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-09-28 04:56:34 +00:00
Allan Sandfeld Jensen
bf76405afc Extend tested formats in lancelot
Adds two formats that does not have optimized code-paths in qdrawhelper
to ensure the generic path has coverage.

This has already uncovered one bug fixed before this patch could go in.

Change-Id: I0e0a1a873555b27f6438f69a76982b8e06263dcf
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-09-27 17:26:03 +00:00
Edward Welbourne
3379ace11b QDateTimeEdit: synchronize time-spec before initializing display
QDateTimeEdit ignores the time-spec of its date-time value, using its
own time-spec instead; mostly, this works because it first conforms
the value to its own time-spec.  However, during construction, before
doing this, it set up its display data, which could leave it with a
different time (rather than a different representation of the given
time) than it was asked to use.

Moved the updateTimeSpec() calls to immediately after setting value in
QDateTimeEditPrivate::init() to ensure correct handling.  Added test.

Task-number: QTBUG-54781
Change-Id: I3b07c10997abb858fc0b40558bff96e3fdabbd83
Reviewed-by: Jesus Fernandez <jesus.fernandez@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-09-27 11:21:53 +00:00
Timur Pocheptsov
158781ff25 QSslSocket: respect read buffer's max size (SecureTransport)
1. QSslSocketBackendPrivate::transmit was ignoring 'readBufferMaxSize';
as a result, we can have a user trying to set read buffer's size
to a small value (and more important - reading slowly in a small
chunks from this socket), but SSL itself socket reading 'too fast',
potentially growing its internal buffer to a huge size. This also
results in auto-tests failing - whenever we're trying to limit read
rate in some test.

2. Update qsslsocket auto-test.

Task-number: QTBUG-43388
Task-number: QTBUG-55170
Change-Id: Iedece26df0ac5b3b7cad62cc8c98aedc28e7ca5b
Reviewed-by: Richard J. Moore <rich@kde.org>
2016-09-27 10:27:58 +00:00
Marc Mutz
b827b8ccf7 Plug memleaks in tst_QGridLayout
In setMinAndMaxSize(), QLayout::removeItem() doesn't actually delete
the removed item. We have to do that ourselves (RAII not necessary,
since the spacer is owned by the layout until we remove it).

In distributeMultiCell(), allocate the QStyle subclass on the stack so
the compiler cleans it up properly on all exit paths (was:
unconditional leak).

Change-Id: I24f8f11af2bfc5abf78f9aab0139dcfe0187402b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-09-27 06:30:34 +00:00
Marc Mutz
77eafa8d89 Plug memleaks in tst_QBoxLayout
In sizeConstraints(), QLayout::takeAt(), as the name suggests, doesn't
actually delete the item. We have to do that ourselves.

Likewise, in replaceWidget(), QLayout::replaceWidget() also doesn't
delete the affected item, but returns it. That's spectacularly bad API
design, but the leak is easy to fix: just delete the return value.

Change-Id: I8dcbc59898949eabce766cda2c0edae2e1f2799e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-09-27 06:30:29 +00:00
Giuseppe D'Angelo
6ea626a32f QObject test: check that throwing from a child's constructor works
A check "just in case" -- we don't want leaks nor crashes
due to double deletions, and so on.

Change-Id: I24f1a486f0d438595bbe352ab780b07c5d53acbd
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-09-26 04:47:06 +00:00
Maurice Kalinowski
55f4957cb8 Fix test for sandboxed platforms
The test function tries to create a file inside the application bundle.

Change-Id: Ia429b42b102d5e98f20694058fa2633e3c7de30a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-09-23 17:06:26 +00:00
Marc Mutz
e2e107556d tst_QGraphicsItem: Fix UB (invalid cast/member call) in prepareGeometryChange()
Found by UBSan:

  tst_qgraphicsitem.cpp:5066:29: runtime error: downcast of address 0x2afcb006c7f0 which does not point to an object of type 'GeometryChanger'
  0x2afcb006c7f0: note: object is of type 'QGraphicsRectItem'
   00 00 00 00  d8 64 ca 98 fc 2a 00 00  40 a9 0b b0 fc 2a 00 00  75 65 29 00 00 00 00 00  35 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QGraphicsRectItem'
      #0 0x4c5f1c in tst_QGraphicsItem::prepareGeometryChange() tst_qgraphicsitem.cpp:5066

Fix by actually instantiating a GeometryChanger, which incidentally is
the pattern used by paint() a few lines below, too.

While at it, allocate the item on the stack (as is done in paint())
and create a local QRectF variable to avoid repeating the same magic
numbers over and over again.

Change-Id: If5a3d56511000a17703d78d7dd1f0ea072b8bc11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-22 15:25:18 +00:00
Samuel Gaist
9f2c260f88 Add missing test for QReguarExpression for QTextDocument::findMultiple
Change-Id: Ia9b3eb21a178da4ae2844dba37b7e1cc669d6b50
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-20 21:23:08 +00:00
Tor Arne Vestbø
fecee98836 multiwindow: Base vsync debug output on actual surface format
Allows us to detect cases where the requested vsync combination was
not possible to fulfill.

Change-Id: Ie8f3665129f7a1ab7fcefb94b2298d54520b753a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-19 00:42:53 +00:00
Tor Arne Vestbø
efdecff085 multiwindow: Replace per window fps timers with unified approach
The FPS is now calculated and output on the command line in a single
place. The animated fps counter has been replaced with a vertical line
which should make it easier to observe tearing issues when vsync is
disabled.

Change-Id: Id356fc1958c048d85aba48edfed59124454038d4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-19 00:42:33 +00:00
Tor Arne Vestbø
880beb121e multiwindow: Call update() after swap
Change-Id: Ic2c26339bce9fe92b2ccc730c72f53ce94397b78
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-19 00:42:28 +00:00
Tor Arne Vestbø
6ce96fdbf5 multiwindow: React to mouse press to allow debugging UI responsiveness
The animated FPS counter should be enough to observe smooth animations,
so we use the color of the window to visualize frame latency.

Change-Id: I1171a1c4bdc261ca8655771290c6735357821781
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-19 00:42:20 +00:00
Tor Arne Vestbø
bcbc8120b3 multiwindow: Use showNormal() instead of show() to ensure normal geometry
Change-Id: Ice607f536a620da5a70f2ba066f4983bb78c6288
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-19 00:42:04 +00:00
Błażej Szczygieł
25c9a6c9b4 QtWidgets: Fix enter/leave events on popup menus
If the sloppy menu popups - send the leave event to the last active
menu (except Cocoa), because only currect active menu gets enter/leave
events (currently Cocoa is an exception).

Check that the menu really has a mouse before hiding the sloppy menu -
don't rely on enter events.

This patch removes some unnecessary synthetic mouse enter/leave events
from QMenu which causes event duplications with different mouse cursor
position.

Refactor sloppy menu timer handling - start or restart timers on mouse
move events. Enter/leave events are not reliable.

Fixes:
- better enter/leave events handling for native widget actions,
- reduce duplicated enter/leave events for menu actions,
- better handle torn off sloppy menus.

Partially reverts: 0ed68f3f58
Amends: 57ecd5aeeb

Task-number: QTBUG-53068
Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2016-09-15 10:16:44 +00:00
Marc Mutz
a54d44298f QLatin1String: Fix UB (nullptr passed) in relational operators
Found by UBSan:

  qstring.h:1160:44: runtime error: null pointer passed as argument 1, which is declared to never be null
  qstring.h:1160:44: runtime error: null pointer passed as argument 2, which is declared to never be null

Fix by avoiding the memcmp() calls if there's a chance that they
might be called with nullptr.

While at it, also implement !=, >, <=, >= in terms of ==, <,
and add a test, because this particular UB was not fingered by
any of the QtCore test cases, but by a Qt3D one.

Change-Id: I413792dcc8431ef14f0c79f26e89a3e9fab69465
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-09-15 10:10:28 +00:00
Milian Wolff
3370ab9119 Never return char variants when reading prepared MySQL statements
This has undesired effects when converting a QSqlRecord to JSON.
A char(0) e.g. has special semantics that are undesired when
reading a Tinyint column.

I don't think that returning bool for the special case of a
Tinyint(1) is required. This also did not happen before, and
is also not happening when not using a prepared statement.
Instead, a plain int/uint QVariant is returned.

This patch extends tst_QSqlQuery::integralTypesMysql to also
cover reading and writing booleans from/to a MySQL table column
of type Tinyint(1). Additionally, the reading is now also done
with a prepared statement and we also check the raw variant
value.

The broken behavior fixed by this patch was introduced by me in
commit 194403a348.

Change-Id: I028a3abd83fdd2b42d98d478950d205e5b6bbeb5
Task-number: QTBUG-53397
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2016-09-12 12:47:08 +00:00
Błażej Szczygieł
3b8df0ea44 QtWidgets: Send show/hide event to children on restore/minimize
Child widgets should get the show/hide event when the TLW changes its
state, because child widgets are also visible or invisible. This
restores the Qt4 behavior (fixes the Qt4->Qt5 regression).

Restoring/minimizing the TLW now sends the spontaneous show/hide event.

Show events are now handled also in the expose event handler in the
QWidgetWindow class, because the show event must occur before the
expose event to avoid possible flicker e.g. the OpenGL content. This
can happen e.g. on XCB platform. If the "WindowStateChange" event occur
before the expose event (e.g. Windows platform) then the code in expose
event handler will be ignored to prevent event duplications.

Added autotest.

Task-number: QTBUG-50589
Change-Id: Ie9a9329b1f29bff876de28d5948d0d5fb6bc1f05
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-09-12 08:38:06 +00:00
Marc Mutz
2a6bea7a55 qcompilerdetection.h: retract Q_COMPILER_DEFAULT_MEMBERS for MSVC < 2015
Earlier versions of the compiler cannot default
move special member functions, even though we
also define Q_COMPILER_RVALUE_REFS for them.

Fix by retracting the less-often-used of the
two compiler feature defines.

Q_COMPILER_DEFAULT_MEMBERS is not used outside
QtBase in neither 5.6 nor 5.7 (5.8 is not
released at this time, so wasn't considered).
The same is true of the dependent macros
Q_COMPILER_DEFAULT_DELETE_MEMBERS and
Q_DECL_EQ_DEFAULT.

In QtBase, the three uses are:
1. in QAtomic*, where the user also requires
   Q_COMPILER_CONSTEXPR, which is not defined
   for any MSVC at this time,
2. for QEnableSharedFromThis, which is a class
   template with an alternative {} implementa-
   tion of the default constructor, and uncon-
   ditional user-defined copy special member
   functions.
3. The test of the corresponding functionality
   in tst_compiler, which this commit amends.

That means that neither of these two only uses
of the macro in Qt libraries are affected by
the change.

The reason we do this change, then, is that in
the future, we want to be able to more easily
restore move special member functions for
classes for which they are suppressed due to
user-defined dtors or copy special member
functions.

Change-Id: I6f88cad66d6b87a758231f16355c3bddae697b86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-03 05:11:40 +00:00
Marc Mutz
312d08b290 qstrncpy: don't call strncpy_s with invalid parameters
According to https://msdn.microsoft.com/en-us/library/5dae5d43.aspx,
strncpy_s' second argument must not be 0:

> If strDest or strSource is NULL, *or numberOfElements is 0*, the
> invalid parameter handler is invoked.

Move the existing check for len > 0 up to protect the strncpy_s
call, too.

Change-Id: I70d339ea60d4b76f3038b2e4e4756f6590a9bd31
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-03 05:07:54 +00:00
Dyami Caliri
816a623876 uic: generate translate calls with Q_NULLPTR instead of 0
uic should use Q_NULLPTR instead of 0 as the default disambiguation
context.

Task-number: QTBUG-45291
Change-Id: I889182c7fe1c4be3336f3cd645aa60838863c633
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-09-03 05:07:50 +00:00
Edward Welbourne
55ab276700 Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths).  Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.

It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs.  This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths.  By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.

In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this.  We may
discover other character entity subsitutions needed along with this.

Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.

The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes.  There are doc-strings;
there is a short usage comment.  Data is localised rather than global
and modern pythonic idioms get used where apt.

Regexes are compiled once instead of repeatedly.  An object looks
after the list of patterns to apply and its construction handles all
anticipated problems.  Failures are mediated by an exception.

The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same.  Its command is delivered as an array, avoiding
the need to invoke a shell.

Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all.  Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).

Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place.  Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).

Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-08-29 18:02:35 +00:00
Samuel Gaist
e52fcb7dc7 QTextDocument: fix string backward search
[ChangeLog][QtGui][QTextDocument] Fixed a bug that would return a wrong
position when searching backward from the end of the document.

Task-number: QTBUG-48182
Change-Id: I6e88f808a50cb840f61e7bc579e2a28c5300089d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-28 15:18:55 +00:00
Friedemann Kleint
1e85ca2e62 QAbstractSpinBox: Clear 'cleared' flag on receiving a keypress
Prevent QAbstractSpinBoxPrivate::interpret() from bailing out
in focus changes after text has been entered.

Task-number: QTBUG-55249
Change-Id: I250b3c50f7db5de2e9356038df20f18ee059df11
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2016-08-25 17:29:51 +00:00
Tor Arne Vestbø
c1804bb5c1 multiwindow: Make it easier to test 1-N windows
Changes the --extrawindows option to --numwindows with a default of 3,
and layouts all windows in rows and columns so that they are all
exposed at startup.

Change-Id: I5e8d63a14b778bcddc2fee3bf7e78d6664532b5b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-24 20:56:28 +00:00
Tor Arne Vestbø
10fe509123 multiwindow: Use QCommandLineParser instead of parsing manually
Change-Id: I9d9e3ede6c8cce3aa1b42d0e98a0a5b19fefc73c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-24 20:56:22 +00:00
David Faure
3e453abc7d QMimeType: use default locale rather than system locale
This makes it possible for the application to control which language
is used by QMimeType::comment()

[ChangeLog][QtCore][QMimeType] QMimeType::comment() now uses the default locale
rather than system locale, so that applications can control which language
is being used.

Task-number: QTBUG-50776
Change-Id: I82623b7c488035a4164fadaf37ebcc79a9fd6173
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-24 20:30:13 +00:00
Tor Arne Vestbø
0f8c2ab3d8 multiwindow: Base fps on number of frames swapped, not timing of last frame
Change-Id: I582e4f35b2702ac3792c5641fa10f74a79351bed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-24 12:39:12 +00:00
Maurice Kalinowski
1e1eddb2de Fix crash in dumpConfiguration
Some qpa backends do not provide a QPlatformNativeInterface. Hence,
check whether return value is valid.

Change-Id: Iab46bc59a151aa244fcfebf58edb37496369db89
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2016-08-23 17:52:47 +00:00
Christian Strømme
5e3f770ad5 Fix problem with exception reporting in QFuture::waitForResult()
This fixes a problem that occurs when a task, that is run synchronously,
throws an exception. If that happened, then the exception would not be
re-thrown, because of an early return.

Task-number: QTBUG-54831
Change-Id: Ic70c5b810ec6adce6e62bfd6832ba9f170b13a7f
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-23 14:55:49 +00:00
Gabriel de Dietrich
0f61cde4d9 Cocoa Menus: Introducing Menurama manual test
This manual test pretends to be a modest safeguard
against QMenu related regressions on macOS. It takes
a slightly different approach than the existing menus
manual test, tracking observed regressions instead of
providing extensive coverage (though this may change
in the future).

These regressions are listed as task numbers below,
most of them arising from the now infamous change,

     09acf326db QCocoaMenu: Decouple NSMenuItem from NSMenu

So, from now on, please run this and the menus manual
tests and look for regressions every time you make a
change regarding QCocoaMenu and related. And, if you're
fixing a regression, add the regression example to the
Menurama manual test.

Task-number: QTBUG-52931
Task-number: QTBUG-53085
Task-number: QTBUG-53251
Task-number: QTBUG-54633
Task-number: QTBUG-54637
Task-number: QTBUG-54698
Task-number: QTBUG-55121
Change-Id: I276e916dcdf00f1a44faf64d87050bc3a037a3b5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2016-08-19 03:04:28 +00:00
Eirik Aavitsland
bc60216945 Remove unneeded dependency on Qt widgets
Widgets module is no longer required. Removing it allows this test to
be run with a qtbase configured with -no-widgets, which saves
compilation time.

Change-Id: Id99d3f25cd7b227aa81e1cf1ac7b6fd5227ac4c4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2016-08-15 08:40:54 +00:00
Topi Reinio
a2ae631c04 Doc: Change instances of '(Mac) OS X' to 'macOS'
As of version 10.12 (Sierra), the name of Apple's desktop operating
system will be macOS. Change the occurrences where the Mac platform
is discussed to use a macro \macos, which expands to 'macOS'. This
helps with adapting to future renaming.

Update the instructions on mac-specific Q_OS_* macro usage.

Add a \target for the old 'Qt for OS X' topic to keep links working
for other documentation modules that try to link with the old name.

Change-Id: Id33fb0cd985df702a4ae4efb4c5fd428e77d9b85
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2016-08-12 08:30:29 +00:00
Marc Mutz
c38ac3dab8 tst_QStringListModel: don't leak memory when tests fail
Simply allocate objects on the stack instead of the heap.

Change-Id: Ic047d78e49668878821cce1c8ab599a8551b6476
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-12 08:28:07 +00:00
Marc Mutz
b57f743c46 QStringListModel: fix dataChanged's roles parameter
In QStringListModel, the display and the edit roles are synonyms,
so when one is changed, the other changes with it. However, in
setData() we only emitted a vector with just the role that was
passed in by the user.

Fix by always passing both roles, regardless of which one was used
to set the data.

Change-Id: I498e7cb33796fae266901817b01ad85d861d4bb4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-12 08:27:53 +00:00
Marc Mutz
3b0ea78603 tst_QSslSocket::setLocalCertificateChain(): fix resource leak when test fail
The deleteLater() call wasn't reliably reached when tests fail,
so use a QScopedPointer with QScopedPointerDeleteLater deleter.

Change-Id: Ica73bc73c2a0ac1e9b77e4804f2aedcad9b662a0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2016-08-11 04:34:19 +00:00
Marc Mutz
08a3a52958 Remove ~tst_QImageWriter
The test no longer writes to SRCDIR, so don't try to remove
generated files from there, either.

Amends bb5570082e.

Change-Id: I1d5df88b1865f3dbd914ec71147de61e173f2f4e
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-11 04:34:14 +00:00
Jędrzej Nowacki
25b72a63ff Fix memory leak in tst_qgraphicsproxywidget
QStyle was created but never removed

Change-Id: I55011377afd475af28e4ce2cf657e435dd37c96a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-08-10 11:06:31 +00:00
Jarek Kobus
385ab06fb1 Always generate size hint for spacer items
Task-number: QTBUG-55008
Change-Id: I53c86b64aa3c0a3e5f80551baefe775c2d4b1e90
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-08-08 07:55:57 +00:00
Edward Welbourne
ceabcc0142 tst_QString: unit test for broken toLocal8bit() error-handling
We can't (at present) actually exercise the failure in
QWindowsLocalCodec::convertFromUnicode() that prompted us to consider
the possible failure here, but we should at least test for it.

Change-Id: I5066c88d7b4caeb48aebc6b79c355fa49e1c581c
Reviewed-by: Frederic Marchal <frederic.marchal@wowtechnology.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-05 12:57:59 +00:00
Alex Trotsenko
1ceee31ae0 Fix tst_QProcess::closeWriteChannel() under Windows
Sometimes, this test fails in CI due to notifications arriving
asynchronously from the OS. This happens inside closeWriteChannel()
call, where we are flushing the write buffer and I/O completion on
the read pipe could occur there as well. So, take this into account
before waiting for the new incoming data. Also, improve the checks
on successful reading and writing.

Change-Id: Iabe875fc346eb4420c72d03208d22ea861a570c6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-08-05 10:16:54 +00:00
David Faure
434c522695 Improve performance of QColor::name, now more than 4 times faster
Before: HexRgb: 0.00230 ms per iteration, HexArgb: 0.00290 ms per iteration
After:  HexRgb: 0.00051 ms per iteration, HexArgb: 0.00061 ms per iteration

This showed up as a relevant optimization when profiling KIconLoader
which uses QColor::name() as part of the key -- thanks to Mark Gaiser for
the investigation and first suggestion of a solution. I have also seen
customer code writing a replacement for QColor::name() because it was
too slow to be used as a hash key.

Change-Id: I009ccdd712ea0d869d466e2c9894e0cea58f0e68
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-05 09:56:12 +00:00
Alex Trotsenko
eb4bcdd8ce QNativeSocketEngine::option(): return a correct value on invalid call
Instead of 'true', it should be '-1'.

Change-Id: I5e8f99153da68d34b37477ef4cedbc447fba347f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-08-05 08:30:18 +00:00
Anton Kudryavtsev
9c8a8e90a6 QString: fix append(const QStringRef &str)
Use QStringRef::isNull instead of QStringRef::string()
for validation. Non-NULL str.string() may yet leave us
with a useless str.unicode(), which is the actual problem here;
whereas !str.isNull() does really confirm that str.unicode()
is sensible.

Such test prevents situation like:

const QString a;
QString b;
b.append(a); // b.isNull() == true
b.append(QStringRef(&a)); // b.isNull() == false

Auto test updated: create QStringRef from QString directly, without
any condition.

Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-04 19:55:04 +00:00
Alex Trotsenko
595c6abf9d QLocalSocket/Tcp: open device before making a connection
According to QLocalSocket's documentation, connectToServer() must
initiate a connection attempt after opening the device. Otherwise, if
a connection succeeds immediately, connected() signal will be emitted
on closed device. So, this patch ensures that TCP-based implementation
behaves correctly.

Change-Id: I4cc9474815e091a1491a429a6dc17f9cf0154f58
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-04 15:25:39 +00:00
BogDan Vatra
bc4ce55fff Don't call virtual functions with data from an old model
Change-Id: I4f1ec56ce722110042f72761bbc2976e580b7149
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-04 11:48:51 +00:00