Consistent with other Unix platforms, and internally consistent between tests,
as a lot of tests were already applying CONFIG -= app_bundle manually.
Change-Id: Icd2b7e1c08015b26137af60ff82fddbc753f0ff4
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
The 'modern' way to run tests is via make check
Change-Id: Idbafa491a1c2e3ba4d9a5ba2bde2350fa0eaf422
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
The QTextDocument::toPlainText() converts some characters in the
text to ASCII, which can be problematic for use cases where you
want to save the precise contents of the document, e.g. in
Qt Creator. Since we don't want to change the behavior of
toPlainText(), we introduce a new function which returns the
raw text contents of the document instead, with no modifications.
[ChangeLog][QtGui][Text] Added QTextDocument::toRawText() function.
Task-number: QTBUG-56538
Change-Id: Ib6c48a16551c4c71c4c431760f993793d1af6806
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
It might happen that, when pressing Alt+X to trigger a shortcut for an
action in a menubar, that the user releases Alt first, followed by X. When
that happens, QMenuBar gains focus as if the user just pressed and
released Alt (to focus the menu bar). That's counterintuitive, frustating
and not what native Windows seems to do.
Fix this by resetting the "altPressed" state whenever a shortcut gets
triggered with the Alt key pressed.
(In the above discussion, X stands for any key).
Task-number: QTBUG-46812
Change-Id: If4b7a47842791894a3a32d09db5de229ed33773e
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
The patch is good, but currently breaks touchmouse test in qtdeclarative.
We need to fix the touchmouse test first, then go ahead and reapply this
patch once qtdeclarative is fixed.
This reverts commit cd26e66c2e.
Change-Id: I222e6240f5ff0eff9c8a3544819499847f6b48fa
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Adds missing image-formats so it doesn't segfault.
Also changes the exclusion of rare formats to lists of included ones
Change-Id: I1d00562cf8e96baa03121a0b996764224911e06a
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
The previous sync() of the specific scope and domain may have failed due
to not having the necessary permissions, but the saved value may still be
cached, so we need to check both.
This was observed on macOS Sierra, where a failed sync() will result in
marking the CFPrefsPlistSource as read-only, eg:
2016-10-04 13:14:11.713271 tst_qsettings[88537:767733] [User Defaults] attempt to set
<private> for key in <private> in read-only (due to a previous failed write) preferences
domain CFPrefsPlistSource<0x6180000e1780> (Domain: org.software.KillerAPP,
User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null))
Change-Id: I8976c1c4acfe2cb0d5510298d5c585faca9607f6
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
WinRT is not the only sandboxed platform. Since it doesn't hurt to keep
the test data in a well known location, we enable the code for all
platforms. We also make sure to mkpath the location, since writableLocation
doesn't guarantee that the location exists.
Change-Id: Ie8d90c5fbdf3b7fbf85ba6be25372b0ef7c4da55
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Before commit f1e9076809, mousePressEvent
called the virtual method setSelection(const QRect&, SelectionFlags)
with the 1x1 rectangle which contains only the clicked QPoint, unless
the SelectionFlag "Current" was set because Shift was pressed during
the mouse press.
Since that commit, the behavior has been changed such that the
rectangle is the one that is spanned by the center of the clicked item
and the clicked pixel. In theory, the result should be the same (i.e.,
only the clicked item should be selected), but
* the code path in QListView::setSelection for 1x1 QRects is more
efficient, and
* using a larger QRect can cause problems with custom views, see the
comments in QTBUG-18009
This commit ensures that the 1x1 QRect is used again, unless the
SelectionFlag "Current" is used.
Change-Id: I70dd70c083c20a3af6cd6095aa89a489756b505f
Task-number: QTBUG-18009
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This allows us to not have conflicts between the point ids between
different devices for QtQuick pointer handlers.
We do this in QtGui because we can then safely compare point ids from
QTouchEvent::TouchPoint and QQuickEventPoint.
(Point ids that QtQuick pointer handlers use will be based on the point
ids provided by QTouchEvent::TouchPoint::id)
Change-Id: I8b9ab0d44224b15175b820d33cbb2d8bd21e99f2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
... and avoid detach()ing potentially large data for just
preserving the QPlatformPixmap::pixelType().
A QBitmap differs from a QPixmap (its base class, urgh)
by always having a data != nullptr and a Bitmap pixel
type, yet load() was unconditionally setting 'data' to
nullptr on failure, turning a QBitmap into a non-QBitmap.
Fix by move-assigning a null QBitmap instead of resetting
'data'.
Add some tests.
Change-Id: Ida58b3b24d96472a5f9d0f18f81cc763edcf3c16
Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
By using _MIN for signed values, and _MAX for unsigned values, we may
detect conversion issues when serializing QVariants using QSettings.
Change-Id: I3ce58ba4b93f791f75c7ae44d1fd5030f07b2f25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This leaves a clearer separation between the foreign-window and non-foreign
window use-cases, where a single QCococaWindow can only be in one mode,
which is determined in the constructor and doesn't change after that.
There are no source or binary compatibility guarantees for the QPA classes,
meaning the helper function in QPlatformNativeInterface can be removed.
Change-Id: I3232aedca1d98c49a8f54e16750832187f9dc69a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
The fix is trivial, but the patch adds a new QSettings tests that iterates most
of the QMetaTypes and verifies that storing and retrieving them again gives the
same value. This is a more complete test than the testVariantTypes tests, which
is limited to a subset of the QVariant types. The new tests borrows logic from
the QMetaType test machinery.
QSettings has been Q_ENUM'ified in the process, for improved debug output.
Note that on backends such as the INI backend, the metatype of the QVariant read
from the settings will be a string, so it won't match the input QVariant type,
but the result of converting that to the original value type should still work.
Task-number: QTBUG-56124
Change-Id: Ib03a26abf77c9fb449b94160d28bc4baeb095f25
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
The slot is invoked from QObject::destroyed(), which is emitted
from ~QObject. By that time the object is no longer a QShortcut,
so the static_cast it invalid.
Found by UBSan:
tst_qshortcut.cpp:1210:53: runtime error: downcast of address 0x6020000289d0 which does not point to an object of type 'QShortcut'
0x6020000289d0: note: object is of type 'QObject'
10 00 80 17 c0 ce 63 df 93 2b 00 00 b0 02 00 00 d0 60 00 00 02 00 00 00 ff ff ff 04 04 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QObject'
#0 0x42b3bb in tst_QShortcut::shortcutDestroyed(QObject*) tst_qshortcut.cpp:1210
#1 0x446cc9 in tst_QShortcut::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) .moc/tst_qshortcut.moc:186
#2 0x2b93dba52c86 in QMetaObject::activate(QObject*, int, int, void**) qobject.cpp:3787
#3 0x2b93dba55400 in QObject::destroyed(QObject*) .moc/moc_qobject.cpp:213
#4 0x2b93dba8d80d in QObject::~QObject() qobject.cpp:967
#5 0x2b93c6b6e032 in QShortcut::~QShortcut() qshortcut.cpp:476
#6 0x2b93c6b6e370 in QShortcut::~QShortcut() qshortcut.cpp:481
#7 0x42a5de in void qDeleteAll<QList<QShortcut*>::const_iterator>(QList<QShortcut*>::const_iterator, QList<QShortcut*>::const_iterator) qalgorithms.h:317
#8 0x42a5de in void qDeleteAll<QList<QShortcut*> >(QList<QShortcut*> const&) qalgorithms.h:325
#9 0x42a5de in tst_QShortcut::clearAllShortcuts() tst_qshortcut.cpp:1136
Fix by replacing QVector::replaceAll() with the erase-remove idiom,
which does not require the cast, because it can perform mixed-type
lookups.
Change-Id: I4251c1895fa4398023f489dbfd7108d90c1a6c94
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
To keep the change minimal, keep 'sw' as a pointer variable,
but back it by a stack-allocated QStackedWidget instead of a
heap-allocated one that's never deleted.
Change-Id: I9e2a8c07979b861eb7e7040c144d8e75c90d0bc9
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Saving strings with embedded zero-bytes (\0) as CFStrings would
sometimes fail, and only write the part of the string leading
up to the first zero-byte, instead of all the way to the final
zero-terminator. This bug was revealed by the code-path that
falls back to storing e.g. QTime as strings, via the helper
method QSettingsPrivate::variantToString().
We now use the same approach as on platforms such as Windows
and WinRT, where the string produced by variantToString() is
checked for null-bytes, and if so, stored using a binary
representation instead of as a string. For our case that
means we fall back to CFData when detecting the null-byte.
To separate strings from regular byte arrays, new logic has
been added to variantToString() that wraps the null-byte
strings in @String(). That way we can implement a fast-path
when converting back from CFData, that doesn't go via the
slow and lossy conversion via UTF8, and the resulting QVariant
will be of type QVariant::ByteArray. The reason for using
UTF-8 as the binary representation of the string is that
in the case of storing a QByteArray("@foo") we need to
still be able to convert it back to the same byte array,
which doesn't work if the on-disk format is UTF-16.
Task-number: QTBUG-56124
Change-Id: Iab2f71cf96cf3225de48dc5e71870d74b6dde1e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
A fair amount of tests are skipped if we can't write to the system scope,
eg on iOS. Without this detection they will fail.
Change-Id: I8257f1f24e69dae88925c20d2bff851e81701405
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
it does not appear that the tests actually use these flags in any way;
they don't include any (actual) d-bus headers and have no ifdefs.
and the qdbus module already pulls in the flags via QMAKE_USE (in the
case where they are defined at all, i.e., dbus-linked).
Change-Id: Ie6bc6da7d1dd96da7b73f2d0fe45576936715874
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The layout isn't actually created until endLayout() or setLineWidth() is
called. So in the case where this was not done, the height of the line
would be 0, thus multiple lines would be placed on top of each other, at
y == 0.
[ChangeLog][QtGui][Text] Fixed QStaticText when manually breaking lines
and no text width was set.
Task-number: QTBUG-56346
Change-Id: I7f6ed6260545882f05fe39b21134315eca7401b9
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
this actually fixes the build when ssl is not enabled, as the openssl
features are in the not included network-private module.
Change-Id: Ibafae9867af493da184a45cf3981628d475d37a6
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
It fails on iOS as well, and likely also tvOS and watchOS.
Change-Id: Idfce98a5aeccb5680f6b4c6e66b526dd7922156d
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Turn the list of newRow() calls into a for loop over a constexpr
data structure.
Fixes the GCC note:
tst_qgraphicsview_2.cpp:47:13: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
and speeds up compilation of the file from 13s to 2.5s on my
machine.
Task-number: QTBUG-38890
Change-Id: I4f0b3565c7df64b286d1d32eb3f3d6bf4df92609
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Added the binary compatibility test data files for Qt 5.7 for QtBase
Change-Id: I5b19571f5e266c52622027d820062afa5fd4fbf3
Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
CFAbsoluteTime is measured in seconds, represented by a double,
so when converting milliseconds to CFAbsoluteTime we may get a
slight error due to missing precision in double to represent
the milliseconds exactly. By rounding to the closest millisecond
when converting back, we avoid truncating and being one ms off.
Change-Id: If1e99f97b000fb8cb893ddfc5d7ba81096c0ea88
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
In tst_QCompleter, two completers were leaked because they
had no parent and setCompleter() calls don't reparent.
Fixed by giving them parents.
In tst_QUndo*, fix lots of leaked QActions by storing them
in a QScopedPointer. There were some half-hearted attempts
to clean them up with manual deletes, but I ported these to
scoped pointers, too, to make the code more robust in the
face of failures.
This fixes the remaining errors in GCC 6.1 Linux ASan runs of
tests/auto/widgets/util.
Change-Id: Icc5248cc9cf4514540915924df1c4d9e09c071fa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
The generated data files for the binary compatibility test
updated for QtBase.
Change-Id: Idae703c83f55ff17cada4419db742ea12b22bf86
Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
The usual:
- delete styles
Either by using QScopedPointer.
This fixes the remaining errors in GCC 6.1 Linux ASan runs of
tests/auto/widgets/styles.
Change-Id: Ifba59085c057d474bf964cbb93010c408d773a61
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
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>
Restore Qt::AA_DontUseNativeDialogs that is disabled in the beginning
of the test function.
Change-Id: I4ff8eab4ecc458c478337824e66b5a59fbdd7c65
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
There's no reason for this to be separated, regardless of the
support status of i386 macOS builds. Additional architectures may
appear in the future (and currently there's actually 3 - i386,
x86_64, and x86_64h for Haswell CPUs). So this feature could be
used to get combined generic x86_64 and Haswell builds. Some
system libraries appear to have an x86_64h slice in Sierra.
[ChangeLog][Build System] Support for universal binaries on macOS
has been re-introduced.
Change-Id: I1c89904addf024431fdb3ad03ea8ab85da7240ad
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
... and move toString() implementations there which were repeated in
network tests, or #ifdef'ed in qtest.h.
Since the functions moved from network tests are now in a public header,
had to massage them a bit to pass headersclean:
- replace Q_FOREACH with C++11 range-for
- avoid implicit conversion from QByteArray -> const char* (done by
re-using toString(QByteArray) instead of calling strdup() manually)
Also made the functions overloads instead of specializations. This
allows to pass the enum by value instead of by const-&.
Like the existing QHostAddress, the newly-added toString() overloads are
marked as \internal. We can decide later whether to turn them into
public API.
Change-Id: I8c23db7a0a6575273567017d42d7b2a957acece8
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
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>
Nested namespaces are quite common, therefore moc should support them.
Task-number: QTBUG-55415
Change-Id: I756cab36d498eb4342b402d255836d5d30f07b30
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
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>
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>
Update fallback mechanism for Q_XDG_PLATFORM based systems to follow the
Xdg specification.
[ChangeLog][QtCore][QSettings] Added proper support for system-wide
configuration file lookup based on Xdg spec (XDG_CONFIG_DIRS) on Unix
based systems
Task-number: QTBUG-34919
Change-Id: Ieddee1c0b3b1506bf19aa865bdab87fc81d58cfd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
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>