Callers can persist a QModelIndex which was not persisted before in a
slot connected to the signal, and such a persisted index must be updated
in the course of the layoutChange.
Store the indexes to persist after emitting the signal.
Task-number: QTBUG-32981
Change-Id: Ibee4c0d84817d72603a03fe5b22fdeefeac0695e
Reviewed-by: David Faure <david.faure@kdab.com>
Similar to the fix in the parent commit, incorrect updating of the
internal data structures during layout changes can lead to dangling
pointers being dereferenced later. Moves are treated as layoutChanges
by this proxy by forwarding to the appropriate method. However, data is
incorrectly cleared prior to that forwarding. Remove that, and let the
layoutChange handling take appropriate action.
Change-Id: Iee951e37152328a4e6a5fb8e5385c32a2fe4c0bd
Reviewed-by: David Faure <david.faure@kdab.com>
In sourceLayoutAboutToBeChanged the source model update is ignored if
the affected parents are filtered out anyway. The same logic is
attempted in the sourceLayoutChanged slot, but there the early-return
logic is applied too late - the mapping is cleared before performing the
early-return. Because pointers into the mapping are used in the
internalPointer of QModelIndexes in this class, persistent indexes used
later will segfault when attempting to dereference it.
Additionally, if a parent becomes invalid as a result of the
layoutChange, it would be filtered out by the condition in the loop,
resulting in a different result in the comparison of emptiness of the
parents container.
Fix that by persisting the parent's container, and performing the test
for early-return before clearing the mapping.
Task-number: QTBUG-47711
Task-number: QTBUG-32981
Change-Id: If45e8a1c97d39454160f52041bc9ae7e337dce97
Reviewed-by: David Faure <david.faure@kdab.com>
Private Use Area characters are quite valid input characters when used
in combination with a custom font. Joiners also serve an important language
purpose in semitic writing systems.
Note that there is a hack where we disregard any character produced
using CTRL or CTRL+SHIFT specifically because of German keyboards. I have chosen to
keep the hack in this patch to limit the change (though I have made an exception
for ZWJ and ZWNJ since both are produced using Ctrl+Shift on Windows), but it
will probably have to be reverted.
[ChangeLog][QtWidgets][Input] Accept characters in Private Use Area, as well as
zero-width joiners and zero-width non-joiners in input in QLineEdit and QTextEdit.
Task-number: QTBUG-42074
Task-number: QTBUG-57003
Change-Id: I73f3b7d587a8670de24e902dc52a51f7721dba5a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Add a bool *ok out parameter to qt_normalizePathSegments() and return false
when ".." are left over for an absolute path, indicating an attempt to
change above root.
Factor out static helper qt_cleanPath() to be able to pass the return value
to QDir::cd() and return on failure from there.
Amends change 63f634322b, which did
not handle UNC paths.
Task-number: QTBUG-53712
Change-Id: I3e63a5dd0259306a0b99145348d815899582f78e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Calling QDir::cleanPath() on "//server/path/.." resulted in "/".
Factor out a function to determine the root path part of an absolute
path for later use, and handle some special cases:
- Consider server name of "//server/path/.." as part of the prefix.
- Check on the root path for WinRT.
Task-number: QTBUG-53712
Change-Id: Ibddacf06212b6fc86fa74a5e4078df6cfd5b66f5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Commit 2bc7a40048 taught the CoreText font database to populate the
families lazily, and in the process added a guard to ensure that we
didn't populate internal fonts (prefixed with a '.'), as these fonts
would then show up in font selection dialogs.
Commit 909d3f5c7 then added support for private fonts, by making it
possible to filter out any private fonts from font selection daialogs.
But the guard was not removed, so we were still not populating these
fonts. This guard has been removed, and the filtering function has
been updated to include the conditions of the guard.
Next, commit e5e93345c5 used [UIFont fontNamesForFamilyName:] to verify
that each family that we registered with the font database would also
have matching fonts when finally populated. This is not the right approach,
as [UIFont fontNamesForFamilyName:] does not handle internal fonts.
Instead we trust what CTFontDescriptorCreateMatchingFontDescriptors()
gives us, but make sure to register the resulting font descriptors
with the original/originating font family, instead of the one we pull
out of the font descriptor.
Finally, as of iOS 10, we can use CTFontManagerCopyAvailableFontFamilyNames
instead of [UIFont familyNames], which gives us all of the internal font
families like on macOS, instead of just the user-visible families. For
earlier iOS versions we manually add '.PhoneFallback', as we know it
will be available even if not listed in [UIFont familyNames].
The end result is that we register and populate families like '.PhoneFallback',
which is critical to supporting more esoteric writing systems.
The check in tst_QFont that styles for a given family is not empty has
been removed, as we can't guarantee that on all platforms, which is
also documented for QFontDatabase::styles().
Task-number: QTBUG-45746
Task-number: QTBUG-50624
Change-Id: I04674dcb2bb36b4cdf5646d540c35727ff3daaad
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
The function was incorrectly handling green and blue color channels
causing them to be dropped. This affects drawing non 32-bit images onto
10-bit per color channels formats such as RGB30.
Change-Id: I9211e253b1a9da0dada5c418d592a8f531265989
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-[NSMenu itemWithTag:] clearly states that it'll return the first
item with that tag. Furthermore, when and item has been synced more
than once, it could be that more than one such item exists in the
same menu (e.g. lately changing the role of Edit->Copy).
Change-Id: I95a4f0a151659ae273ba03a3cab4a720b781fc3a
Task-number: QTBUG-57404
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This should not happen, but it's clearly not the user's fault.
So we should try to carry on as gracefully as possible instead
of letting Cocoa abort the application.
The patch also factors the repeated calls to QCocoaMenuItem::
nsItem() in QCocoaMenu::insertNative() and improves a warning
from QCocoaMenuIten::sync().
Change-Id: Id00135c219aaf40fb565b19a65cab68f6d9863b2
Task-number: QTBUG-57404
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
QHostAddress allowed assignment from a QString, but the respective
constructor is explicit, and rightfully so. So it does not make
sense that the assignment operator is provided, because of the
asymmetry caused between
QHostAddress addr = funcReturningQString(); // ERROR
addr = funcReturningQString(); // OK (until now)
By the same token, since SpecialAddress is implicitly convertible
to QHostAddress, provide the missing assignment operator from that
enum.
Add tests, rewriting the _data() function to use the enum instead
of an int to pass SpecialAddress values, and to test !=, too.
Added setAddress(SpecialAddress), since a) it was missing and
b) to share code between the ctor and the assignment operator.
Change-Id: Ief64c493be13ada8c6968801d9ed083b267fa902
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Several people agreed that the name was confusing and that this one
is better.
Task-number: QTBUG-54616
Change-Id: I31cf057f4bc818332b0551a27d1711599440207c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Sune Vuorela <sune@vuorela.dk>
Change 3370ab9119 introduced
warnings from MSVC:
tst_qsqlquery.cpp(4005): warning C4805: '==': unsafe mix of type 'const bool' and type 'int' in operation
tst_qsqlquery.cpp(4059): note: see reference to function template instantiation 'void runIntegralTypesMysqlTest<bool>(QSqlDatabase &,const QString &,const QString &,const bool,const T,const T)' being compiled
with [ T=bool ]
tst_qsqlquery.cpp(4006): warning C4805: '==': unsafe mix of type 'const bool' and type 'int' in operation
tst_qsqlquery.cpp(4006): warning C4804: '/': unsafe use of type 'bool' in operation
tst_qsqlquery.cpp(4026): warning C4804: '+=': unsafe use of type 'bool' in operation
Extract an overload taking a QVector of values and use that for the
bool case instead of looping over min/max to generate a sequence of values
for bool.
Change-Id: I72583774e788b8df899f22ed1a64278217e664f6
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
The alpha channel of an RGB32 image was not properly ignored when doing
blending with partial opacity.
Now the alpha value is properly ignored, which is both more correct
and faster. This also makes SSE2 and AVX2 implementations match NEON
which was already doing the right thing (though had dead code for
doing it wrong).
Change-Id: I4613b8d70ed8c2e36ced10baaa7a4a55bd36a940
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
- Declare as Q_MOVABLE_TYPE
- Prevent QList<QPointerUniqueId> from being instantiated
(use QVector instead)
- Add equality relational operators
- Add qHash() overload
- Replace non-default ctor with named ctor.
- Add Q_DECL_NOTHROW.
- Add Q_DECL_CONSTEXPR.
- Rename numeric() -> numericId().
- Update docs.
The extension vector for this class calls for additional
properties to be added later, but these are not user-
settable. It thus suffices to rely on the only data
member, a qint64, which can be reinterpreted to an index
into an array or hash with actual objects. This allows
to make the class a Trivial Type (ie. no overhead over
an int) while still supporting later extension. Cf.
QSslEllipticCurve as another example of such a class.
The extension has to maintain the following invariants,
encoded into user code by way of being used in inline
functions:
- m_numericId == -1 <=> !isValid()
This is trivial to support. An extension could not and
still cannot reinterpret the qint64 member as a d-pointer,
but a d-pointer is only necessary for user-settable
properties where updating a central private data structure
would cause too much contention.
Add a test.
Since this type is used in other modules, keep the existing
functions, but mark them as deprecated with the expectation
that these compat functions be removed before 5.8.0 final.
Task-number: QTBUG-54616
Change-Id: Ia3ede0ecaeeef4cd3ffa94a72b1050bd409713a5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
We parse the EXIF header in order to get the proper orientation, so
let's be a bit more careful in what we accept. This patch adds better
handling for reading past the end of the stream, plus it limits the
number of IFDs read (to avoid processing too much data) and deals with a
pathological case of the EXIF file format: EXIF (due to its TIFF
origins) permits the offset to the next IFD to be backwards in the file,
which means it could result in a loop or pointing to plain corrupt data.
We disallow any backwards pointers, since it seems that's what other
decoders do (libexif, for example).
Change-Id: Iaeecaffe26af4535b416fffd1489332db92e3888
(cherry picked from 5.6 commit 02150649f95b8f46f826e6e002be3fa0b6d009bc)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
If 5ca9631d3a is reverted, this test
segfaults on Unity most of the times.
Task-number: QTBUG-55966
Change-Id: Ice59842e0a1a7930e3cd10c4c7319ef033fe6a58
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Q_UINT64_C appends a literal, which causes warnings:
tst_qtextstream.cpp(2026): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2030): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2031): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2032): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2289): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2309): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2329): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2355): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2381): warning C4146: unary minus operator applied to unsigned type, result still unsigned
tst_qtextstream.cpp(2411): warning C4146: unary minus operator applied to unsigned type, result still unsigned
Change-Id: I69ac87c224b75aff059477362d8a317c7e766ec2
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
.. instead of manually casted 0s.
QCOMPARE(., nullptr) was added for Qt 5.8. Make use of the new API.
In tst_qwidget.cpp, as a drive-by, change
qApp->focusWidget() -> QApplication::focusWidget()
Change-Id: I1331b8916b026d48e01534d1ed0b3d72f3f3d50c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
tst_qtcpsocket.cpp:606:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
tst_qtcpsocket.cpp:670:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
tst_qfile.cpp(2661): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
tst_qarraydata.cpp(760): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
main.cpp:40:33: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
Change-Id: I80ccef29b71af6a2c3d45a79aedaeb37f49bba72
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
The check for 8x zoom was inverted and checked for 1/8x zoom.
Change-Id: I45156db709bab6b702769c2a70d4d2af51b5533a
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Compare to QLatin1String and use reinterpret_cast to fix MSVC warning:
tst_qstring.cpp(1271): warning C4312: 'type cast': conversion from 'unsigned int' to 'void *' of greater size
Change-Id: I4f26d72f0fad59e09636fe609a2772309a688e5c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
../tst_qfile.cpp: In member function 'void tst_QFile::handle()':
../tst_qfile.cpp:2661:38: warning: ignoring return value of 'ssize_t read(int, void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]
tst_qstatictext.cpp:862:58: warning: unused parameter 'textItem' [-Wunused-parameter]
../tst_qtcpsocket.cpp: In member function 'void tst_QTcpSocket::abortiveClose()':
../tst_qtcpsocket.cpp:2254:90: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
Test.cpp: In member function 'void My4Socket::read()':
Test.cpp:66:20: warning: 'reply' may be used uninitialized in this function [-Wmaybe-uninitialized]
../tst_qlocalsocket.cpp: In lambda function:
../tst_qlocalsocket.cpp:701:51: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
../tst_qtcpserver.cpp: In member function 'void tst_QTcpServer::linkLocal()':
../tst_qtcpserver.cpp:935:92: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
../tst_qtcpserver.cpp:940:92: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
Change-Id: Ic315069768bcb63a6b333c28ac65b0b992b0d43f
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Fix warning about unused variable printer in auto-test and redirects
output to qInfo() as intended.
Amends change a26435d65c.
Change-Id: Ia72a93267a54b9c4f9ef37fa058b95ef586ecc75
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Looks up the canonical names of enumerated fonts and register them under
their preferred names if present.
Also changes the logic handling registration of english aliases, so it
is always done, even if it might in rare cases cause a double
registration since that is safe.
Task-number: QTBUG-53458
Change-Id: Ia010774b26072192b55697b717cc37442c852881
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
The prior test deemed there to be narrowing if source and destination
integral-or-enum types didn't have the same signedness; but all values
of an unsigned source type can be represented in a larger signed
destination type, so there is no narrowing in this case.
Updated QObject test-case to match.
Change-Id: I517a5997adcad70e185d7469a8d26788e463cb75
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
By templating on the <chrono> types and unconditionally using
duration_cast to coerce the duration into a milliseconds, we
allowed code such as
mutex.try_lock_for(10us)
to compile, which is misleading, since it's actually a zero-
timeout try_lock().
Feedback from the std-discussions mailing list is that the
wait_for functions should wait for _at least_ the duration
given, because that is the natural direction of variance
(tasks becoming ready to run might not get a CPU immediately,
causing delays), while an interface that documents to wait
_no more_ than the given duration is promising something it
cannot fulfill.
Fix by converting the given duration to the smallest number
of milliseconds not less than the original duration. If that
is not representable in an int, use INT_MAX, emulating the
effect of a spurious wakeup, which are allowed to happen if
the function returns false in that case.
In the above example, the try_lock_for call is now equivalent
to
mutex.tryLock(1);
The tryLock() docs state that the actual waiting time does
not exceed the given milliseconds, but fixing that is a
separate issue.
Change-Id: Id4cbbea0ecc6fd2f94bb5aef28a1658be3728e52
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The code coerced a -123 into a QFormLayout::ItemFlags, which, however,
being an enum with enumeration values 0..2, only has valid numerical
values 0..3.
Fix by using 3 as the value to represent the invalid enum value, and
store this in a constant so as not to distribute this magic number
all around the test class.
Change-Id: Ie5e93a69ef5a3acdde43030b022e0cce8aec484d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
The logo (microsoft.windows.softwarelogo.showdesktop.exe) is otherwise
not found.
Change-Id: Ic52329462612a027e2928922a1f9a541dcbc67a3
Reviewed-by: Jesus Fernandez <jesus.fernandez@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
The time stamp is added at the end of the node information and
consequently this also bumps the version.
Task-number: QTBUG-57182
Change-Id: Ia10e006f28c0b168b2bcd74ed8b7098f84d10af3
Reviewed-by: hjk <hjk@qt.io>
Change the main window to contain a QTabWidget and add a log widget
logging relevant events on the top level widgets for testing changes.
In the preview window, add new window flags of Qt 5 and output
geometry, margins and window state in addition.
Change-Id: Icec366223b6c163d58a69034687f3d9323a91533
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Chaining hooks together was mentioned by Ossi in the comments of
d953d9a4. This patch justs add a test that verifies that it works, and
also serves as an informal example for developers looking how to do it.
Change-Id: I53a014d5663c289ea0559e0926ed301f4e5110e6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
A test was directly accessing the .text member of QDateTimeParser
(which presently has nothing private). Use the virtual .displayText()
method of this base instead, to let the base have some hope of
data-hiding (maybe, some day).
Change-Id: I8b6e39fba130de56f117bffb2aec346197969c5b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This test fails on Windows occasionally with values just short of 800, the lowest
observed being 791. It is probably rounding somehow to 10ms segments, so allow
it to be up to 10 ms too fast.
Change-Id: Ie28e9f61588b68a9060a006f78eedc3a26d05155
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
QModelIndex is not safe to be used to store an index as it is designed
to be discarded right after use as the index information can change.
Therefore a QPersistentModelIndex should be used instead to store the
index. Subsequently the m_index does not need to be updated whenever
the model changes anymore as this is already done for us.
Task-number: QTBUG-49907
Change-Id: Icc93e410de2821c503ea15a7a1dd9ae32634914e
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
GCC warned:
tst_qtablewidget.cpp:30:
tst_qtablewidget.cpp: In member function ‘void tst_QTableWidget::mimeData()’:
qtestcase.h:66:52: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))\
^
tst_qtablewidget.cpp:1523:5: note: in expansion of macro ‘QVERIFY’
QVERIFY(data = table.mimeData(tableWidgetItemList));
^~~~~~~
Fix by adding the extra parentheses, as usual.
Change-Id: I2826d7a865b4113b468d5a958ede06e03aa0e278
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>