Commit Graph

27372 Commits

Author SHA1 Message Date
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
Giuseppe D'Angelo
874852d625 QMap: remove statement about STL support during Qt's own configuration
Since STL support is mandatory in Qt 5, the sentence is a tautology
and can be removed.

Change-Id: I8676368cc917aa00a85b1113ed2a47694427b2ce
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-08-07 07:43:29 +00:00
Simon Hausmann
131b7c8f64 Fix permissions on lock files on Unix
We should create the files with 0666 and let the umask take care of adjusting
to the final permissions in the file system.

[ChangeLog][QtCore][QLockFile] Fixed permissions on lock files on Unix to
allow for adjustments via umask.

Change-Id: Iee6a6ac3920d0ffd4465f54ac6e955f7fe087173
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-05 14:27:04 +00:00
Simon Hausmann
4e6440acf8 Improve reliability of callgrind benchmark results
When running under callgrind, do not bother with the use of the watchdog. The
constructor waits for the thread to start, which adds an overall run-time cost
that depends on the OS scheduling.

Change-Id: I162e2e311c43a6892ebc67dea39899e40babb61d
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-08-05 14:25:58 +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
Kai Koehne
b92f5a0f3b Remove hiding of .main div in offline pages
The section got introduced in commit 93d35c07d0, but is
ignored by browsers so far due to a non-blank space (0xc2 0xa0).

Task-number: QTBUG-55115
Change-Id: Ie0668b89c7151c934f40e033100a544011a583d8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-08-05 12:45:19 +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
Jesus Fernandez
4cb44c744c Added pointer check in QFontDatabase::load
CID 11131 (#1 of 1): Dereference after null check (FORWARD_NULL)46.
var_deref_op: Dereferencing null pointer fe.

Change-Id: Ifc0cd0b208db511516db93c3d0e0367299df6d80
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2016-08-05 10:05:49 +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
David Faure
91a2c8630b QUrl::resolved: keep treating file:name.txt as relative for now
8a33077 made QUrl::resolved() follow its documentation ("If relative
is not a relative URL, this function will return relative directly.",
where relative means scheme is empty).
However there is much code out there (e.g. qtdeclarative) which relies
on QUrl::fromLocalFile("fileName.txt") to be treated as relative, so
for now, we still allow this (in Qt 5.6.x). For Qt 5.8, this commit will
be reverted.

[ChangeLog][QtCore][QUrl] [EDITORIAL: replaces 8a33077] QUrl::resolved()
no longer treats a URL with a scheme as a relative URL if it matches
this URL's scheme. For now it still treats "file:name.txt" as relative
for compatibility, but be warned that in Qt 5.8 it will no longer
consider those to be relative. Both isRelative() and RFC 3986 say that
such URLs are not relative, so starting from Qt 5.8, resolved() will
return them as is.

Change-Id: Iff01e5b470319f6c46526086d765187e2259bdf5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-08-04 19:55:30 +00:00
Jake Petroules
47511046a4 Fix rasterwindow example
At least with the eglfs platform plugin, the QBackingStore constructor
results in a null pointer access if done before creation.

Change-Id: I2e78e70700fa48499a35c55797e1b962b6e6285a
Reviewed-by: Rebecca Worledge <rebecca.worledge@theqtcompany.com>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2016-08-04 19:55:14 +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
Kai Pastor
35117590c8 Remove unneeded ';' after some macros
The unneeded ';' triggered warnings in pedantic compilation mode.

Change-Id: Id2324823e138560bb25234306601253d7bbd713e
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-08-04 19:52:18 +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
charlycha
457d91bb07 raspberry pi: manage eglfs display id with env var
Specify the display to use by setting environment variable
QT_QPA_EGLFS_DISPMANX_ID Possible values are :
0: MAIN LCD
1: AUX LCD
2: HDMI
3: SDTV
4: FORCE LCD
5: FORCE TV
6: FORCE OTHER

Change-Id: I146db9a7f423bd4c6c1716c64d3df4d2388e85f9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2016-08-04 15:23:09 +00:00
Allan Sandfeld Jensen
b643d6f347 Fix 64-bit bilinear scaled image sampling
A constraint ensuring we do not sample beyond the current scan-line
was missing in the SSE2 optimized sampling.

Discovered with lancelot.

Change-Id: Ib0ece8f8bfaa034733873dc5b8baaaad5d4c0380
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-08-04 12:01:04 +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
Kai Koehne
f200d5e824 Doc: Fix references to Control, Meta key enums
Also make use of qdoc's \note command.

Change-Id: I276300cfcfde06e82b04793dbf25df8ec73e9838
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-03 13:45:00 +00:00
Marc Mutz
ed38f516bf QStringListModel: begin/endResetModel() are no signals
... so don't use emit on them.

Just confuses readers.

Change-Id: I24365fc533b5b35f8942d6014dbc68387aa23e22
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-08-03 12:10:00 +00:00
Friedemann Kleint
d1a30be5ab Polish the findfiles example to be actually useful
- Simplify the code, remove unused members
- Fix the translations of plurals to use %n
- Add tooltip displaying full paths in list
- Add context menu allowing to copy the name and  open
- Display the correct slashes on Windows
- Connect the returnPressed() signals of the line edits
- Make the search recursive
- Do not search binary files by checking the mime type

Change-Id: I3663799c88931db1f58c03ea35211e7ab03737ec
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-03 11:53:55 +00:00
Friedemann Kleint
d5be0d3058 Polish the codecs example
- Port to Qt 5 connection syntax.
- Remove unneeded member variables.
- Adapt to screen size.
- Add a tab widget with a hex dump view to the preview dialog.
- Handle conversion errors in preview dialog,
  add status label displaying errors and warnings about failures
  and invalid characters encountered.
- Fix translated messages.

Change-Id: I916100c903e73d0d2326523753ed7398b1c34df0
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-03 11:53:47 +00:00
Clemens Sielaff
2a24c3c268 Fixed Bug in QVariant comparison when containing QStringLists
As it were, QStringLists were not handled explicitly when comparing
QVariants. If both QStringLists contained only a single entry, they
were treated as QStrings - if both QStringLists were empty, there were
equal (correctly so) - but if one of the QStringLists had more than
one entry, the compare function fell through to returning always 1.
As discussed here:  https://stackoverflow.com/a/38492467/3444217

Added rich comparison tests for all non-numerical, non-recursive
QVariants that support them (except QModelIndex and
QPersistentModelIndex)

Task-number: QTBUG-54893
Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-08-03 11:16:35 +00:00
Friedemann Kleint
dbb5c95f4d Windows QPA: Handle key event sequences of surrogates
Emoji characters as input by the virtual keyboard are received
as a sequence of surrogates. Store state internally when a high
surrogate is received and send off the sequence when the matching
low surrogate is received via input method.

Task-number: QTBUG-50617
Change-Id: I91e763ec3e0747d6852f7c5c2057a67b0c24e0f5
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2016-08-03 06:12:36 +00:00
Friedemann Kleint
9b1db44c2a Polish charactermap example
- Use Qt 5 connection syntax.
- Introduce helper function to calculate the square size, remove
  the existing 24 pixel limitation since that makes it impossible
  to render 20pt fonts.
- Add filter chooser for font filters.
- Add menu and info dialog showing DPI and default fonts.
- Streamline code

Change-Id: I0cd4d0475b5a7ed3c475de7a413abebbe688dfe2
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-08-02 18:57:49 +00:00
Edward Welbourne
879fd5bb5c QTzTimeZonePrivate: skip redundant check, tidy up
Various transition functions checked on m_tranTimes.size() > 0 inside
a block which was conditioned on this already; simplify the code by
knowing this is true already.  Tidied up an initializer at the same
time.

Change-Id: I3e933a69e1b71b94bfd4451e4d761844da669d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-02 08:57:21 +00:00
Mitch Curtis
b92a63f707 Fix typo in QMessageBox documentation
Change-Id: I879817bf0209db331a9b1ef206bad7aa5b8a678f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-08-02 08:30:22 +00:00
Marc Mutz
5dc83974f7 tst_QTreeView: Fix UB (invalid downcast, member call)
As reported by UBSan:

  tst_qtreeview.cpp:2187:36: runtime error: downcast of address 0x7ffc15749f20 which does not point to an object of type 'PublicView'
    0x7ffc15749f20: note: object is of type 'QTreeView'

Fix by making the test a friend of QTreeView (and, for
Clang, of QAbstractItemView) instead.

Change-Id: I5b748696ab441a91058f4d45a18bd5ed75a6e560
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-01 16:07:50 +00:00
Marc Mutz
08f38d2214 tst_QAbstractItemView: Fix UB (invalid downcast, member call)
As reported by UBSan:

  tst_qabstractitemview.cpp:336:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
   0x7ffe6fe96e10: note: object is of type 'QListView'
  tst_qabstractitemview.cpp:337:5: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
   0x7ffe6fe96e10: note: object is of type 'QListView'
  tst_qabstractitemview.cpp:338:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
   0x7ffe6fe96e10: note: object is of type 'QListView'
  [etc ...]

Fix by making the test a friend of QAbstractItemView instead.

Change-Id: I1a08977042296eb34e9dbdb5c0595662dbd2e5ef
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-08-01 16:07:40 +00:00
Marc Mutz
a81be85b63 QDataWidgetMapper: Fix UB (member call)
As found by UBSan:

  qdatawidgetmapper.cpp:212:59: runtime error: member call on address 0x2b6cc8095be0 which does not point to an object of type 'QFocusHelper'
  0x2b6cc8095be0: note: object is of type 'QLineEdit'

Just make QDataWidgetMapperPrivate a friend of QWidget.

Change-Id: I33d8d430c3a03b7173358d0f96dc7f850d11697c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-08-01 16:07:24 +00:00
Marc Mutz
d38f86e50b QColor: remove 158 avoidable relocations
Instead of storing a pointer to a string, store the string
in the RGBData struct. It's not as efficient as in other
such cases, because one string is particularly long, but
it's still more than acceptable.

Text size increases slightly, but data size decreases a lot
(can't say by how much, exactly, as I'm on a UBSan build).

Change-Id: I1df2985fd1ebfccd84b48315d8d319dd9e25c8e7
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
2016-08-01 16:07:16 +00:00
Olivier Goffart
49c8923282 QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal
We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might
be filtering extra items.

The documentation of QAbstractItemModel::LayoutChangeHint states:

    Note that VerticalSortHint and HorizontalSortHint carry the meaning that
    items are being moved within the same parent, not moved to a different
    parent in the model, and not filtered out or in.

And some of the views rely on this assumption (QQmlDelegateModel for example)

What happens in the test is the following:
- 'model' emit the dataChanged signal when its data is changed.
- 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward
  the dataChanged signal imediatly, it will instead first re-sort the model and
  call layoutAboutToBeChanged / layouChanged with the VerticalSortHint
- 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in
  QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping
  which will cause the changed data to be filtered.
So proxy2 can't forward the VerticalSortHint as it removed rows in the process.

Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-08-01 14:08:15 +00:00
Eskil Abrahamsen Blomfeldt
6f423555eb REG: Fix unwanted cache flush in Freetype engine
The Freetype cache was almost completely disabled by
134c6db858 because after that
change, the lockedAlphaMapForGlyph() function would no longer
cut off early for empty glyphs like spaces, but rather go
through all alpha map functions before it realized that there
was nothing to render. This would in turn invalidate the cache
for every empty glyph, causing all glyphs to be rerendered for
every isolated word.

This change adds back a cut off. This is only needed in the
lockedAlphaMapForGlyph() function, since the superclass implementation
of the other alpha map functions already contains a cut off for
width/height == 0.

[ChangeLog][Qt Gui][Text] Fixed a performance regression in Freetype
engine that was introduced in Qt 5.5.

Change-Id: I381285939909e99cc5fb5f3497fecf9fa871f29a
Task-number: QTBUG-49452
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-01 11:58:02 +00:00
Eskil Abrahamsen Blomfeldt
3f1048cca7 Android: Fix CJK text with Android 7.0
In Android 7, some fonts are packed in .ttc files. We fix this
simply by including them when populating the font database.

Freetype supports this and in fact,
QBasicFontDatabase::populateFontDatabase() also adds *.ttc.

[ChangeLog][Android] Fixed CJK font resolution on
Android 7.

Task-number: QTBUG-53511
Change-Id: Iebe51b0e6ba2d6987693306cd9a12013ce886b58
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2016-08-01 11:52:13 +00:00
Marc Mutz
b55221cf50 Fix UB (invalid enum value) in tst_QTreeView
As reported by UBSan:

  tst_qtreeview.cpp:663:5: runtime error: load of value 4294967295, which is not a valid value for type 'DragDropMode'

Instead of abusing -1 to indicate to not set the dragDropMode,
use a separate boolean field in tha data.

Change-Id: I13e7539c858f3b2462d57d660062ef3cb7aec61b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-31 14:22:29 +00:00
Marc Mutz
4ac28eda8e QTreeWidget: Fix UB (member call)
Before actually deleting QTreeWidgetItems from QTree{Model,Widget{,Item}} dtors,
their 'view' members need to be set to nullptr, lest they attempt to delist
themselves from the list of top-level items.

For the QTreeModel::headerItem, this was forgottten.

Found by UBSan:

  qtreewidget.cpp:1488:70: runtime error: member call on address 0x7ffd843dd470 which does not point to an object of type 'QAbstractItemView'
  0x7ffd843dd470: note: object is of type 'QWidget'
    #0 0x2b83d5b48323 in QTreeWidgetItem::~QTreeWidgetItem() src/widgets/itemviews/qtreewidget.cpp:1488
    #1 0x2b83d5b48860 in QTreeWidgetItem::~QTreeWidgetItem() src/widgets/itemviews/qtreewidget.cpp:1535
    #2 0x2b83d5b41659 in QTreeModel::~QTreeModel() src/widgets/itemviews/qtreewidget.cpp:143
    #3 0x2b83d5b41bc0 in QTreeModel::~QTreeModel() src/widgets/itemviews/qtreewidget.cpp:146
    #4 0x2b83df220747 in QObjectPrivate::deleteChildren() src/corelib/kernel/qobject.cpp:2010
    #5 0x2b83d4603dd0 in QWidget::~QWidget() src/widgets/kernel/qwidget.cpp:1675
    #6 0x2b83d4d76066 in QFrame::~QFrame() src/widgets/widgets/qframe.cpp:256
    #7 0x2b83d5270442 in QAbstractScrollArea::~QAbstractScrollArea() src/widgets/widgets/qabstractscrollarea.cpp:575
    #8 0x2b83d5733eb9 in QAbstractItemView::~QAbstractItemView() src/widgets/itemviews/qabstractitemview.cpp:617
    #9 0x2b83d598b216 in QTreeView::~QTreeView() src/widgets/itemviews/qtreeview.cpp:206
    #10 0x2b83d5b218b6 in QTreeWidget::~QTreeWidget() src/widgets/itemviews/qtreewidget.cpp:2549
    #11 0x4eef42 in tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget() tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp:1089

Change-Id: I57c277adee8c99eb07b274d6d8ea1f6fbf3575be
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-31 14:21:43 +00:00
Marc Mutz
b37539442f QColor: Fix UB (left shift of negative number)
If hex2int(const char*) is called with invalid input, it is expected to
return a negative value. However, it didn't check the return value of
h2i() before attempting a left-shift on it, leading to UB when the first
digit was already invalid.

UBSan agrees:

  qcolor_p.cpp:55:23: runtime error: left shift of negative value -1

This is particularly worrisome as the function can be called with
unsanitized input.

Fix by checking each value for non-negativity, returning -1 early
when errors are detected.

Also port to QtMiscUtils::fromHex() and add some docs.

Change-Id: I33dbc157ffb4fbfba27113a0a008eef35c1055f7
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-31 14:21:38 +00:00
Marc Mutz
8740a87841 QAbstractItemView: Fix UB (invalid downcast)
Just use QWidgetPrivate::get() instead.

Fixes UBSan error:

  qabstractitemview.cpp:3814:61: runtime error: downcast of address 0x2b859001aa70 which does not point to an object of type 'QAbstractItemView'
    0x2b859001aa70: note: object is of type 'QWidget'

Change-Id: I0460fd8a0681e122d440755ebf07018d273b93f8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-31 14:21:27 +00:00
Marc Mutz
068ce0b10c QRasterizer: fix UBs involving << with a negative LHS
Left-shifts of negative values are undefined in C++. In particular,
they don't behave arithmetically.

Reported by UBSan:

  qrasterizer.cpp:609:48: runtime error: left shift of negative value -640/-2240
  qrasterizer.cpp:982:38: runtime error: left shift of negative value -2

Fix by using ordinary multiplication instead, because negative
left-hand-side values don't look like they are an error.

No errors were actually reported for a.y << 10, but I changed it
nonetheless, since all a missing error means is that the test data
didn't excercise this code path with negative Y values.

Change-Id: I1fa9deca263f12206a3f7eab6ad875fc3242269d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-07-30 10:01:56 +00:00
Konstantin Shegunov
f0685992a3 Docs changed to reflect that valueName is required with value parsing
When the option expects a value the valueName parameter of the
constructor isn't optional; it must be set. This requirement is made
explicit in the documentation.

Task-number: QTBUG-54855
Change-Id: I190884aff2fa8e96bc5c5e82cdfed85be761d6e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2016-07-29 21:18:07 +00:00
David Faure
8a33077853 QUrl: fix resolved() for data URLs
They look relative because the path doesn't start with a '/' but they
have a scheme so they shouldn't be combined as if it was one absolute
and one relative URL.

[ChangeLog][QtCore][QUrl] QUrl::resolved() no longer treats a URL with
a scheme as a relative URL if it matches this URL's scheme. This special
casing was incompatible with RFC 3986 and broke resolving data: URLs,
for instance.

Change-Id: I3758d3a2141cea7c6d13514243eb8dee5d510dd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-29 17:51:51 +00:00
Marc Mutz
8141d64527 qgrayraster: fix UBs involving << with a negative LHS
Left-shifts of negative values are undefined in C++. In particular,
they don't behave arithmetically.

Reported by UBSan:

  qgrayraster.c:510:19: runtime error: left shift of negative value -1/-42
  qgrayraster.c:537:26: runtime error: left shift of negative value -1/-4/-128
  qgrayraster.c:538:26: runtime error: left shift of negative value -1/-4/-128
  qgrayraster.c:641:28: runtime error: left shift of negative value -1/-42
  qgrayraster.c:676:44: runtime error: left shift of negative value -1/-4/-5/-14/-129
  qgrayraster.c:807:19: runtime error: left shift of negative value -1/-42
  qgrayraster.c:1101:9: runtime error: left shift of negative value -32/-46/-224/-8160
  qgrayraster.c:1102:9: runtime error: left shift of negative value -32/-2626
  qgrayraster.c:1454:36: runtime error: left shift of negative value -32/-96/-224/-466/-2626/-8160
  qgrayraster.c:1535:30: runtime error: left shift of negative value -32/-46/-224/-2626/-8160

Fix by using ordinary multiplication instead, because negative
left-hand-side values don't look like they are an error.

Change-Id: I2e96de51adb4a030de8a49869ddd98a31dab31b3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2016-07-29 16:22:31 +00:00
Denis Kormalev
f24cc53cc2 Fix for race condition in signal activation
There was a race condition between QObject::disconnect() and
QMetaObject::activate() which can occur if there are multiple
BlockingQueued connections to one signal from different threads and
they connect/disconnect their connections often.

What can happen in this case is:
T1 is in activate() method and T2 is in disconnect() method

T1                          T2
locks sender mutex
selects next connection
unlocks sender mutex
                            locks sender mutex
                            sets isSlotObject to false
creates QMetaCallEvent      derefs connection
posts event

Two things can happen here:
1. Connection can still be valid, but it will have isSlotObject==false
and callFunction will be used instead of slotObj
2. Connection can already be invalid

To fix it mutex unlock should be moved after QMetaCallEvent creation.

Also there is another case, when we don't disconnect but delete the
receiver object. In this case it can already be invalid during
postEvent, so we need to move mutex unlock after postEvent.

Change-Id: I8103798324140ee11de5b4e10906562ba878ff8b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2016-07-29 06:09:22 +00:00
Marc Mutz
10d4969966 examples: use QSignalBlocker
Examples should show idiomatic Qt, and QSignalBlocker is idiomatic
since it's inception in Qt 5.3. Just updating the examples was
forgotten.

This commit makes good for that.

Fix coding-style issues as a drive-by.

Change-Id: If138e87ea2ab7a444599734113f7cc6df11fb42d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-07-28 23:43:32 +00:00
David Faure
4790ccfa7a Fix gcc -Wsuggest-override warning on Q_OBJECT
Same reasoning as commit 3092bd5 (which was for Clang), but for gcc >= 5.1.

Change-Id: I123b17670c1a64876b01fd39fb11648fa4e8b1fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2016-07-28 23:43:16 +00:00
Alexander Volkov
695d85363e Item delegates: show localized detailed tooltips and "What's this?" texts
Extract the common part from QItemDelegate and QStyledItemDelegate
which uses QLocale to convert a value for Qt::DisplayRole to a string.
Use this code to get the text for tooltips and "What's this?".

[ChangeLog][QtWidgets][QAbstractItemDelegate] Show localized detailed
tooltips and "What's this?" texts.

Task-number: QTBUG-16469
Change-Id: I8618763d45b8cfddafc2f263d658ba256be60a15
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2016-07-28 23:42:56 +00:00
Błażej Szczygieł
444ba31a0a xcb: Don't activate bypassed windows on mouse press
Windows with "Qt::BypassWindowManagerHint" flag can't be activated by
mouse. They can be activated only from code calling "activateWindow()"
or "requestActivate()" methods.

The patch applies also for "Qt::ToolTip" and "Qt::Popup" windows which
have implicit "Qt::BypassWindowManagerHint" flag.

The patch fixes some major issues:
- don't activate tooltips on mouse press - this causes that Qt "thinks"
that original windows loses its focus causing e.g. that text cursor
stops blinking,
- don't activate X11 tray icon - this causes that the active window
looses its focus by clicking tray icon.

The patch restores the Qt4 behavior.

Task-number: QTBUG-53993
Change-Id: I80b226f2f5ea0ebbfe8922c90d9da9f4132e8cce
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2016-07-28 18:16:01 +00:00
David Faure
f5af4428c3 QVector: fix crash on reserve(0)
It crashed when d was equal to Data::unsharableEmpty().

Task-number: QTBUG-51758
Change-Id: If9f2a7d11892507135f4dc0aeef909f59b7478fc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-07-28 13:50:38 +00:00
David Edmundson
ebb651aa73 Handle device pixel ratio in QTreeWidget animations
As we are rendering into a new paint device we need to copy the device
pixel ratio from the widget.

Task-number: QTBUG-50207
Change-Id: Ica99ae84fe04311edfef817ab719863d627faf64
(cherry picked from commit 49491dd678)
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2016-07-28 07:15:27 +00:00
Friedemann Kleint
d12a284bbb Windows QPA: Pass ExcludeUserInputEvents to QWSI::flushWindowSystemEvents()
User Input events flushed out by those calls have been observed
to cause crashes.

Task-number: QTBUG-39842
Change-Id: I950b80f2863def5b28e9fe46ef2b73aa6db2592f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2016-07-27 17:21:03 +00:00