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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The native sizes returned by the metrics and theme functions refer
to the primary monitor. They need adaption when showing on a secondary
monitor with differing logical DPI.
Introduce a helper function
QWindowsStylePrivate::nativeMetricScaleFactor() to calculate the
total factor.
Task-number: QTBUG-49374
Change-Id: I34c843ff34108424e1ef0aafcf9f563d17ebbc89
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This is in preparation of fixing a design problem with indexEditorHash.
Change-Id: I6045ad3f15cd3087a894b96e9e068e42af7a1dea
Reviewed-by: hjk <hjk@qt.io>
This is a partial revert of a4e2f2e687.
That fix tried to avoid the risk of a crash in pixel() by ensuring
Mono QImages created with external data also got a default color
table. However, that broke usable behavior in existing code that was
painting in Mono QImages using color0/color1.
This commit reverts to the old behavior, and instead expands on the
checking in pixel() so that lacking color table is handled gracefully
for all indexed formats.
Task-number: QTBUG-54827
Change-Id: I9164198bed9d20c4b12cdba40a31c141bef3128d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
When font antialising is disabled, the created alpha maps will be Mono
format. Make sure that the created QImage is valid by ensuring that
it has a color table of the right size.
Issue was earlier handled by a4e2f2e687,
but that will be partially reverted because of compatibility break.
Task-number: QTBUG-50745
Change-Id: I7c521288469ae94805a3326644771270d97ab979
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Disable the scrolling optimization in QBackingStore
and fall back to repainting for non-integer deltas.
The existing rendered pixels are not re-usable in
this case.
The test is made on the delta, and not on the scale
factor. This means that user code can cooperate and
generate (logical delta, scale factor) combinations
that result in integer pixel deltas (which _can_ be
scrolled).
Change-Id: I36eb5d9e00449428bc9095edd8732782b996db16
Task-number: QTBUG-52452
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
[ChangeLog][Platform Specific Changes] It is now possible to opt out from
installing signal handlers when running with eglfs and linuxfb by setting
the QT_QPA_NO_SIGNAL_HANDLER environment variable to a non-zero value.
Task-number: QTBUG-54733
Change-Id: Ib07d4bbf714c752631c49b76ad0a16677c1ba5bd
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Trying to move closer to GL semantics: it is allowed to destroy
a GL context at any time and that must free all of its resources.
Change-Id: I3daa81d721cf26baf86a1a6435b77e3c28feb1a2
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
The QPixmap methods are gone in Qt5. QtWinExtras should be used instead.
Task-Id: QTBUG-54838
Change-Id: Ia52ab9786f57d92caf4c44142a3131dbf973a193
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
The screen number has been observed to be -1 in setups
with multiple virtual desktops.
Amends change eb50193136.
Task-number: QTBUG-52735
Change-Id: If01acf74fdd701a9211df732c0defdfd522ba72d
Reviewed-by: hjk <hjk@qt.io>
When the mouse wheel step is set to "Scroll one screen", querying
SPI_GETWHEELSCROLLLINES returns the special value unsigned(-1). Return the
default instead of converting it to int in that case since Qt does not
implement it.
Task-number: QTBUG-52384
Change-Id: I793e5c09103fe0c7c4a378aba97e9f63ae1c2f35
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
On macOS, the test script is passed the full path to the compiler, like
/usr/local/bin/icpc. That doesn't match "icpc".
Change-Id: I149e0540c00745fe8119fffd1463c87b8f6a89b2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
QMacPasteboard's dtor skips LazyRequest promises and this leaves pasteboard
manager in broken state, since we release the pasteboard itself
of the next step in destructor. As a result, not only Qt's app doing D & D
(and thus via QCocoaDrag creating a stack-allocated QMacPasteboard) can die
suddenly when somebody inspects a pasteboard, this 'somebody' ... can also
die amazingly. So now we DO resolve promises using PasteboardResolvePromises
(but we also preserve the original intent of not providing or providing empty
data for lazy requests).
Task-number: QTBUG-54663
Task-number: QTBUG-54832
Change-Id: I3ce90bd0a012dd3cbb30c93b2b17dce9473acb28
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Child window positions should not be mapped back and forth by High DPI
scaling as this can cause them to change screens or be moved to invalid
locations.
Introduce a separate branch for child windows applying only size
constraints.
Task-number: QTBUG-54420
Change-Id: I4f86666952a49ed6fa03234a04031bc406281c45
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Known ICC bug, still present in version 17 beta.
qdatetime.h(126): error #3280: declaration hides member "QDate::jd" (declared at line 136)
Obviously a parameter to static function or to a function in a nested
class can't shadow an NSDM.
Intel issue IDs: 0000698329 / DPD200245740
Change-Id: I149e0540c00745fe8119fffd1463c679a3a9c8c3
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
alphaChannel.convertToFormat() may fail due to OOM. Check the obtained
image.
Task-number: QTBUG-54873
Change-Id: I778b7de7de611105fe23c1c24cbd69bd8f7c72d9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Change e109b8a0f3 introduced a
performance regression when rapidly switching fonts as long as
the number of different fonts is over a relatively small number, since
the cost of fonts can be high compared to the limits set on the cache.
Since the original patch was intended to avoid exceeding the
open file limit when using Freetype on Windows, we add an
additional check on the number of engines in the cache as well
for the added, synchronous cache flush.
The limit is set to 256 to make it unlikely that it is exceeded
during a single paint event, but it can also be configured when
building Qt if a higher limit is needed.
[ChangeLog][QtGui][Text] Fixed performance regression when rapidly
switching between a large set of fonts.
Task-number: QTBUG-54180
Change-Id: I92b9fbe14fca4f11c9c6dfdcdbec6d19a61b86a7
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Since Xcode 8 (beta 2) that tool is no longer available
through xcrun. We resort to xcodebuild instead.
Change-Id: If9d7b535c1cbac2caae0112b2003283aeff34fb9
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
these are the two signals unhelpfully suppressed by system(2).
Change-Id: I5e5df9f6d136601f0f36a8d645f90a1cab9995ad
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The number of bytes to write was converted to a 32bit unsigned value,
causing losses. Change the type to qint64 and adapt the code determining
the block size.
Task-number: QTBUG-54870
Change-Id: I294da5bfe97c7e60f67228399e1244a1aba4c89c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Should be reverted when https://github.com/android-ndk/ndk/issues/142 is fixed.
Change-Id: Ie68807062247bee4969bc9aa00b0221c8147fed7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Calling QOpenGLContext::surface() on a non-current context will
likely return NULL, so the code path that tried to reset
the old context as current would actually fail.
Change-Id: Ibbc8da877740a596aa7dd0af8ccffb9a1877290a
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Since Android 5.0 Google introduce a nasty bug[1] which calls
JNI_OnLoad more than once.
Basically every time when a library is loaded JNI_OnLoad is
called if found, but it calls *again* JNI_OnLoad of its .so
dependencies! So, JNI_OnLoad of libQt5Core.so gets called may times,
this is not a problem as long as it's called from Qt's java delegate
class loader. The problem is that the application .so file *must* be
called from default class loader to allow the user to find his custom
Activity/Service stuff.
[1] Workaround https://code.google.com/p/android/issues/detail?id=215069
Change-Id: Ia71209658ef56056b560018597608acf7cb0f9ea
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Without this change, Qt Creator tags this example as "broken"
and hides it from the Examples tab in the Welcome mode.
Change-Id: If1982495ec68f5cebb931f5e9498258af21f5aa7
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>