If QObjectPrivate::declarativeData is set, it is
in various places in Qt expected to point to a
QAbstractDeclarativeDataImpl, from which ownedByQml1
is unconditionally read.
In noDeclarativeParentChangedOnDestruction(), the
declarativeData pointer is, however, set to a local
QAbstractDeclarativeData instance, which, being an
empty class, has size 1 and alignment 1.
Depending on the compiler's idea of bit field order,
this code either read uninitialized data from the
dummy object, or else some random stack memory outside
any (valid) object.
What caught UBSan's attention, though, was the
difference in alignment between the two classes:
src/corelib/kernel/qobject.cpp:917:9: runtime error: member access within misaligned address 0x7fffc9cf706f for type 'struct QAbstractDeclarativeDataImpl', which requires 4 byte alignment
Fix by providing a properly initialized object of the
correct type.
Change-Id: Iae83a949ee5a7bc98df13e35ea614c063085fa13
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Don't pass around meta-type IDs in QMetaType::Type
variables. It leads to reading values from an enum
variable that are invalid.
Fix by passing the IDs around as int.
Found by UBSan:
tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp:408:5: runtime error: load of value 4028, which is not a valid value for type 'Type'
Change-Id: Idd106ee3d7960fe3d8fefc0fc5830fc22d38a513
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
The reinterpret cast from a QTcpSocket → QAbstractSocket → QIODevice
to MyIODevice → QIODevice was undefined.
Fix by simply instantiating a MyIODevice, which must then inherit
from QTcpSocket, of course.
Instead of fixing the class name in the overridden setOpenMode()
method, simply make the base class' implementation public with
a using declaration.
Found by UBSan:
qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp:84:22: runtime error: member call on address 0x7ffcca2d23f0 which does not point to an object of type 'MyIODevice'
0x7ffcca2d23f0: note: object is of type 'QTcpSocket'
Change-Id: I939b3548949b9b5765df4a6cc81875e169fd69dd
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
When a high-priority event is posted in overrided
'QStateMachine::beginSelectTransitions', the event may be remained in
event queue, and be not dispatched until another event posted.
Change-Id: Ifda288d9c00ac7985e426b9cc02bda382ebaac35
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
When the byte sequence for a BOM occurs in the middle of a utf8 stream,
it is a ZWNBSP.
When a ZWNBSP occurs in the middle of a utf8 character sequence, and the
SIMD conversion does some work (meaning: the length is at least 16
characters long), it would not recognize the fact some charactes were
already decoded. So the conversion would then strip the ZWNBSP out,
thinking it's a BOM.
The non-SIMD conversion did not have this problem: the very first
character conversion would already set the headerdone flag.
Change-Id: I39aacf607e2e068107106254021a8042d164f628
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QByteArray::operator< and friends had their logic reversed.
Task-number: QTBUG-48350
Change-Id: I625209cc922b47e78dfb8de9fe100411f285a628
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The timeZone() function used to assert when called on such an object
(or, for a release build, return an invalid time zone).
Change-Id: I6ae8316b2ad76f1f868e2498f7ce8aa3fcabf4a6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
To handle network events, QEventDispatcherWin32 uses I/O model
based on notifications through the window message queue. Having
successfully posted notification of a particular event to an
application window, no further messages for that network event
will be posted to the application window until the application
makes the function call that implicitly re-enables notification
of that network event. With these semantics, an application need
not read all available data in response to an FD_READ message:
a single recv in response to each FD_READ message is appropriate.
If an application issues multiple recv calls in response to a
single FD_READ, it can receive multiple FD_READ messages
(including spurious).
To solve this issue, this patch always disables the notifier
after getting a notification, and re-enables it only when the
message queue is empty.
Task-number: QTBUG-46552
Change-Id: I05df67032911cd1f5927fa7912f7864bfbf8711e
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Disable input and cursor for QGuiApplication instances used in
autotest to initialize it properly.
Change-Id: I78dc9b776269c082c20f244a51f858289129275d
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
An invalid mime magic definition could lead to an assert. Replaced with
a qWarning. Move all checking to the QMimeMagicRule constructor, and do
keep invalid rules since they are need to parse child rules.
Unit test added, with QTest::ignoreMessage when using the XML backend
(there's no warning from update-mime-database when using the cache).
Also make it easier to add more shared mime info files for tests.
Task-number: QTBUG-44319
Done-with: Eike Ziller <eike.ziller@theqtcompany.com>
Change-Id: Ie39a160a106b650cdcee88778fa7eff9e932a988
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QDateTime::addSecs needs to do something similar, but not identical
because it needs the number of days too. And then there are daylight
savings transitions...
Task-number: QTBUG-47717
Change-Id: I7de033f80b0e4431b7f1ffff13f976f4f5e5a059
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Playing with the offset argument of pcre_exec is not equivalent to
adjusting the pointer to the subject string. In particular, PCRE
can go behind the offset to check for lookbehinds or "transition"
metacharacters (\b, \B, etc.).
This made the code that deals with QStringRefs not matching in behavior
with the corresponding code dealing with QStrings. For instance,
QString subject("Miss");
QRegularExpression re("(?<=M)iss");
re.match(subject.mid(1)); // doesn't match
re.match(subject.midRef(1)); // matches!!!
Instead, actually adjust the pointer to the subject string so that
the behavior is identical. A broken test that relied on the
equivalence is also removed.
Change-Id: If96333241ef59621d7f5a6a170ebd0a186844874
Reviewed-by: Volker Krause <volker.krause@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Give setStandardOutputFile2 a sensible name, move it to where it
belongs and remove bogus Q_OS_WINCE ifdef.
Change-Id: I5c843e8b6cb626979966f3e61f7a7c720173bb28
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Do not call bytesAvailableInChannel if the source pipe end is
invalid. This is the case when redirecting channels on Windows.
The assertions in bytesAvailableInChannel were triggered whenever
an output process or output file was set and waitForBytesWritten
was called.
Task-number: QTBUG-45548
Change-Id: I225dfea2c5e27e122f75008a3a06d425554e00fe
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
The generated xml file is now lowercase.
This was changed in shared-mime-info 3805d0bcf2.
It led to runtime warnings "No file found for ...", which helped notice the bug.
Change-Id: I31f0fc7f0fe8a098c3f79c0bcbeeb1909d2cc05a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The buffer may have been left dirty if we were unable to write all the
data to the child process in the previous run. So ensure we clear it
before starting a new one. We already did that for stdout and stderr,
for some reason.
Task-number: QTBUG-44517
Change-Id: I1a800c709d3543699131ffff13c419da3bbffacf
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
It failed on Windows due to readonly files copied from the resource,
until adding a setPermission call.
Change-Id: I1d42b53763583aca73d011e0f2bbf061ef6aa891
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
On Windows and OS X, where QStandardPaths does not use XDG_DATA_DIRS/
_HOME and shared-mime-info is not installed, the tests that require
additional shared mime info xml files were never run.
Mend that by using QStandardPaths' test mode instead of setting
XDG_DATA_HOME.
Change-Id: I53b75c293c41c4dac63986dcb88972c2b54d5428
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
[ChangeLog][Important Behavior Changes] QDebug output for QStrings
changed compared to Qt 5.5.0 to more closely match the output of
previous Qt versions. Like Qt 5.5.0, QDebug will escape non-printable
characters, the backslash and quote characters, but will no longer
escape the printable characters.
Task-number: QTBUG-47316
Change-Id: I52dd43c12685407bb9a6ffff13f62ef68cbc80c5
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Otherwise, on some systems (Windows), we'll always create the same dirs.
Change-Id: Id3d5c7bf4d4c45069621ffff13f79ba91e0f974b
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
[ChangeLog][QtCore][QLoggingCategory] Fixed behavior of default
severity passed to constructor or Q_LOGGING_CATEGORY with regards to
QtInfoMsg, which was previously treated as being more severe than
QtFatalMsg.
This is because the code was using the numeric value of QtMsgType as a
proxy for severity (via the <= operator), but the value of QtInfoMsg is
greater than QtFatalMsg. Instead, the severity ordering must be dealt
with explicitly.
Change-Id: I5f178afc735221b00cb67c2cea4fa964bd9079ce
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
All overloads of QProcess::start will now check whether the program
string is empty and in that case
- set error to FailedToStart,
- set errorString to "No program defined",
- emit error.
Until now only one of the three overloads behaved like this.
As a side effect, start(QString(), QStringList()) will not crash on
Windows anymore.
Task-number: QTBUG-47404
Change-Id: I2f93657204fe3643b1d74a74817843c05fc4a96b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Set QFileDevice::WriteUser on all files extracted from resources. These
are read-only, which is preserved by QFile::copy(). This caused the
deletion of the temporary directory to fail on Windows.
Change-Id: Id99de9160471c38bcec68025c89cfabbe209bdbe
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
On Windows, having read-only files in a directory can cause removal
to fail. When file deletion fails, check on the permissions, set
write permissions and retry.
Split apart code paths by OS in tst_QDir::removeRecursivelyFailure();
deletion of the read-only directory on UNIX should still fail.
Change-Id: I36e54be5229a7b552e90fd5f42722b868fa0b6ee
Reviewed-by: David Faure <david.faure@kdab.com>
An object that throws in its constructor cannot be reentered. This
violates both C++11 and C++98. It's also a regression from MSVC 2013.
The unit test is renamed to indicate what it really does, as opposed to
a misleading name that was probably a "thinko" on my part.
Task-number: QTBUG-47224
Change-Id: Ib306f8f647014b399b87ffff13f132436d0578ef
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
QTemporaryFileEngine does not store the pattern, so it needs to get it
again from QTemporaryFilePrivate prior to reopening the file. It's
possible to lose the pattern when remove() is called on the object.
Task-number: QTBUG-46156
Change-Id: I66a35ce5f88941f29aa6ffff13dfc7f83d4fa3a2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: David Faure <david.faure@kdab.com>
On Windows, t->timeout was updated only once, at creation time, so the
timer would always show as "overdue" after the first activation.
The timer is updated to indicate the full remaining time during the slot
activation, which is the behavior of the Unix and Glib dispatchers.
Task-number: QTBUG-46940
Change-Id: I255870833a024a36adf6ffff13ecadb021c4358c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Conflicts:
src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
Manually fixed src/testlib/qtestcase.cpp to return the right type.
Change-Id: Id1634dbe3d73fefe9431b9f5378846cb187624e4
The rationale being that the empty string is not a valid path component.
[ChangeLog][QtCore][QDir] QDir::relativeFilePath() now returns "."
instead of an empty string if the given path is the same as the
directory.
Change-Id: Ibcf31904b2ae5edf5639d4c2e5ba234365d347fd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Since of Windows (Phone) 8.1 most of the desktop's thread functionality
is also available, so we might be able to share the code and get rid of
the extra implementation for WinRT.
Task-number: QTBUG-43837
Change-Id: I0ce907cd94899834527f88c70e1e395bafdb14b3
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
The Intel compiler defaults to "fast math" mode, which is why those
tests had been failing. So for the test that is trying to check whether
we conform to IEEE strict requirements, turn on strict requirements.
Change-Id: I02f8426b1c8e4241ac10ffff13e8efa224f313b2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Since Connection can be copied, one copy could be used for
disconnecting, but the other's d_ptr wouldn't get updated and would
continue to report as still connected.
This patch fixes that by making it check the internal state. That is
only done after d_ptr is already known to be non-null. Unfortunately,
that is the common path:
if (connect(sender, &Sender::signal, [] {}))
will call an out-of-line function. I don't see a way out.
Task-number: QTBUG-46213
Change-Id: I66a35ce5f88941f29aa6ffff13dfb45dca68a350
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Global (application-level) event filters are supposed to be run only in
the main thread, so ensure that it is the case.
Change-Id: I27eaacb532114dd188c4ffff13d5a17d991b8bd2
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
... and enable auto-deletion on it.
This allows users of the function to get rid of their own
cleanup code. They just need to keep the shared pointer alive
for as long as they need it.
Drive-by changes:
- replaced QStringLiterals that were only used as the rhs of op+
- replaced an instance of mid() used as the rhs of op+ with midRef()
- enabled NRVO
Change-Id: I161d39461e020c9e8d473c0810dea2109fe0d62d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Zero is a legitimate size to be returned by bytesFree/bytesAvailable
functions, so change those functions to return some 'invalid' size
in case of an invalid drive.
This is also consistent with the original version from the Qt Systems
framework.
[ChangeLog][QtCore][QStorageInfo] Fixed sizes returned for invalid drives.
Task-number: QTBUG-45724
Change-Id: I312fba521fdf8d52d7a0ac0e46cacca625775e80
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Previously, QStandardItem::operator<() returned true when both
items had invalid data. With MSVC in debug mode (checked
iterators/STL), this triggered an assert in
tst_QStandardItem::sortChildren() since that verifies
that !(b < a) when a < b:
Debug Assertion Failed!
Line: 3006
Expression: invalid operator<
Introduce a stable sort order for invalid items such that
other items are always less than invalid items and comparing
invalid items returns false (indicating equivalence).
Change-Id: Ica0f0d9f001c86973b1941dbcc1faf282e4c47df
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Give the link a name containing time stamp and ensure
it is deleted.
Change-Id: I846c58095acbcd92e7daccfd43a69dd97e95e7b0
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Previously, the path was removed from list returned (indicating failure
to remove) only when the thread's list was empty
(last file in directory). Move the statement up so that removal
happens when it is found in thread's list.
Task-number: QTBUG-46449
Change-Id: Ib79199c731f79357b0e5c17636254fbeb3a754a0
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
As discussed on the development mailing list, the new overload is ambiguous
and breaks source compatibility. Therefore this function that is new in 5.5
shall be called readLineInto.
Change-Id: I2aecb8441af4edb72f16d0bc6dabf10cdabf32e2
Reviewed-by: Jan Kundrát <jkt@kde.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Do not try to automatically register the meta type for Q_GADGET that
are not default constructible.
This fixes a source incompatibility in the function pointer syntax
of QObject::connect when such types are used as an argument of a signal.
Task-number: QTBUG-45721
Change-Id: I3065f6d57bc1f37e16988d2dee99118de250ca56
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
To cover the situation that the process ID got reused, the current
process name is compared to the name of the process that corresponds
to the process ID from the lock file.
If the process names differ, the lock file is considered stale.
[ChangeLog][QtCore][QLockFile] Detection of stale lock files got more
robust and takes the name of the process that belongs to the stored
PID into account.
Task-number: QTBUG-45497
Change-Id: Ic3c0d7e066435451203e77b9b9ce2d70bfb9c570
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
Otherwise the type is registered with the wrong name
Change-Id: I68ec3a05e2528816626e648b46ccc9d70b004866
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Include class name, object name and file name when available.
For the bug in question:
QIODevice::read: device not open
becomes
QIODevice::read (QTcpSocket, "QFtpDTP Passive state socket"): device not open
Adding a static function also makes it easier to set a breakpoint
and find the culprit.
Task-number: QTBUG-46112
Change-Id: Ic181d8ab292912d1acbcc3cb84d9679fe4842ca0
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Otherwise, make check does nothing, always succeeding.
Change-Id: I0fe04697e02ab0f33cd9aebb550777e200c70804
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>