Because on Windows, the .ini files are saved with CRLF, but the files in
the Qt resource are just LF (.gitattributes makes them so).
Task-number: QTBUG-25446
Change-Id: I5eab0d9620bd1ba675b0a87c554f62cef0f98fcc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Implements isNull for QVariants of a nullptr so they always return
true to isNull(), instead of depending on how they were constructed.
Task-number: QTBUG-58296
Change-Id: Ibddec795cdadedef7e17d22c265c29e752d8f99f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Do not wait up to the timeout ms after already having waited several
times. At the same time upgrade to using the QDeadlineTimer which
is designed for this purpose.
Change-Id: Iaf5e4f4655605d5143ce91040c6eb6706752e504
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove the qWait() and introduce a QTRY_COMPARE()
checking for the end value first.
Task-number: QTBUG-58402
Change-Id: I2d3758178de5f67881008f28c406076ad27c4a90
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Use QTRY_COMPARE with a timeout to check for the stopped state
unless BAD_TIMER_RESOLUTION is defined.
This speeds up the test by 1s and prints diagnostic information
should an interval be too short (as seems to be the case on macOS,
currently).
Change-Id: I8f884cd66ad33314124d3130d9f49606e6dfe9f3
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
C++17 adopts P0021R1[1], which makes noexcept be part of the function
pointer's type and thus be overloadable. It contains some provisions for
allowing a noexcept function pointer to cast implicitly to a non-
noexcept function pointer, but that fails in the presence of templates
and additional overloads that could match the type in question.
Fortunately, the paper proposed a test macro, so we can change our
sources now and be compatible with both C++14 and C++17 rules.
This first failed with Clang 4.0 trunk. This source incompatibility is
not our fault, it's the language's doing.
[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
Task-number: QTBUG-58054
Change-Id: I2bc52f3c7a574209b213fffd14988cf0b875be63
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
The population of data rows was factored into a separate file, qutf8data.cpp, in
commit e20c4730. Merge commit 9bd03235 failed to track a conflicting change into
the new file, and brought the code back into the tst_utf8.cpp, where it has been
duplicating the utf8data data ever since.
Change-Id: I4282685b882448f927289468bd7ab340a21ea0b3
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
For language "Traditional Chinese" on iOS with region "US",
the logic was formerly to attempt a match on country/language/script (fail),
followed by country/language (which would result in script defaulting to
"Simplified"). Now, the logic is to try language/script first if script is
specified. Failing that, language/country will be attempted.
Task-number: QTBUG-39639
Change-Id: I75a774b1e66686e95167ff221458a97a7ea2660d
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jason Erb <jason.erb@sparist.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The future tests don't need QtConcurrent as QFuture and friends are in
QtCore. The printdevice test doesn't use QtNetwork and the lancelot as
well as the testlib tests don't use QtXml.
Change-Id: I150ac99b36682aa23ad22ba943266eb0f0952838
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
We have to enable qt_safe_ftok with either sharedmemory or
systemsemaphore. In order to make the resulting QT_CONFIG work with the
bootstrap library we switch the features off for bootstrapping. Some
tests and examples have to be excluded when sharedmemory is not
available.
Change-Id: I3fc3926d160202b378be2293fba40201a4bf50c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
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>
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>
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>
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>
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>
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 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>
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>
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>
Do not consume white-space after a token before the token has been
parsed, otherwise we end up with misleading offsets. This also fixes
a wrong error of illegal number in several cases.
Change-Id: I492ca4de0346a1d0ab73b1c23d7a72dba812664c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Add better boundary checks and catch (hopefully all)
cases where invalid binary JSON could cause crashes.
Change-Id: I206510b7c5e3ba953802a5f46645878e65704ecc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Any other use than for enums should use std::is_[un]signed. Make this
explicit by renaming the type traits.
Change-Id: I494158563c95c710e710d0d337f4e547006df171
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Since the macro is now just a wrapper for std::is_enum,
its use is also deprecated.
[ChangeLog][QtCore][Global] Q_IS_ENUM is deprecated.
Use std::is_enum<>::value instead.
Change-Id: I09b9f4559c02c81f338cace927873318f2acafde
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove most type traits from qtypetraits.h, but keep the custom
implementation of is_signed/is_unsigned. This gets rid of
BSD-3 licensed code from Google in a public header (hugh!).
The custom implementations for is_signed/is_unsigned are kept
because the implementations in gcc's standard headers do not
work as we expect for enums - both is_signed and is_unsigned
always returns false there - see also
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027
[ChangeLog][QtCore][General] Qt now relies on type traits from
the C++ standard library.
Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Adds a few missing parts of the conversion from QVariant to QJsonValue
after the introduction of the nullptr QVariant. The conversion the other
way is already implemented.
Change-Id: I8b25dec4b476c4761c5098a60944ff11c36f8bec
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Apparently, the CI can run something over 1000x slower than on my
machine. We're getting over 100 ms delays in operations that shouldn't
have taken more than half a millisecond. The last report was of 136%
over budget, so I multiplied the resolution by 4.
Change-Id: I9093948278414644a416fffd1474406967b2a6ee
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
The file descriptor has been closed and this test is checking if we get
EBADF.
Change-Id: I33dc971f005a4848bb8ffffd1478eaffd99aa2e9
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This will be done by all POSIX APIs for strings coming in that way, but
because other code (like NSWhateverViews) will most likely return
decomposed form, we make sure that those are in composed form too.
Task-number: QTBUG-55896
Change-Id: I065e11cee6b59706d4346ed20d4b59b9b95163b8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
All strings coming out of POSIX API calls are converted to composed form
by QFile::decodeName. Do the same for realpath(3) output. This is
especially important for HFS+, which will store file names in decomposed
form, and APIs will therefore return strings in decomposed form.
Task-number: QTBUG-55896
Change-Id: I5e51f4e5712ff26bf9644cbcf9a9603995748892
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
The Qt::ISODate format strips milliseconds, so a new format is introduced
that keeps the milliseconds. A new format was chosen over fixing the
existing format due to the behavioral change of suddenly having ms
as part of Qt::ISODate.
Change-Id: If8b852daed068cce8eee9b61a7cd4576bc763443
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
By templating on the <chrono> types and unconditionally using
duration_cast to coerce the duration into a milliseconds, we
violate a principal design rule of <chrono>, namely that non-
narrowing conversions are implicit, but narrowing conversions
need duration_cast. By accepting any duration, we allow non-
sensical code such as
QTimer::singleShot(10us, ...)
to compile, which is misleading, since it's actually a zero-
timeout timer.
Overloading a non-template with a template also has adverse
effects: it breaks qOverload().
Fix by replacing the function templates with functions that
just take std::chrono::milliseconds. This way, benign code
such as
QTimer::singleShot(10s, ...)
QTimer::singleShot(10min, ...)
QTimer::singleShot(1h, ...)
work as expected, but attempts to use sub-millisecond
resolution fails to compile / needs an explicit user-
provided duration_cast.
To allow future extension to more precise timers, forcibly
inline the functions, so they don't partake in the ABI of the
class and we can later support sub-millisecond resolution by
simply taking micro- or nano- instead of milliseconds.
Change-Id: I12c9a98bdabefcd8ec18a9eb09f87ad908d889de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.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
Cherry-picked: 764f5bf48c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
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>
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>