This reverts commit 90de48493be283b9afb249f6a0fd8dbd8958517d.
The call isn't necessary, but invokes undefined behavior.
It invokes undefined behavior because deleteTLSysExtra() is called
from deleteExtra(), which is called from ~QWidgetPrivate(), which is
called from ~QObject(). Thus, by the time we call q->windowType()
within setWinId(), q is no longer a QWidget, but only a QObject, and
calling a QWidget member function then is UB.
UBSan confirms:
qwidget_p.h:300:5: runtime error: downcast of address 0x2afdd4053620 which does not point to an object of type 'QWidget' (the Q_Q macro)
0x2afdd4053620: note: object is of type 'QObject'
qwidget.cpp:1712:93: runtime error: member call on address 0x2afdd4053620 which does not point to an object of type 'QWidget'
0x2afdd4053620: note: object is of type 'QObject'
It is also unnecessary:
deleteTLSysExtra() is called from two places: QWidget::destroy() and
deleteExtra(). deleteExtra() is only called from ~QWidgetPrivate()
which is only called from ~QObject() called by ~QWidget(), which,
however, already calls QWidget::destroy(). QWidget::destroy(), in
turn, unconditionally (for non-desktop widgets, at least) calls
setWinId(0) itself.
So fix the UB by removing the call without replacement.
Conflicts:
src/gui/kernel/qwidget_qpa.cpp
Change-Id: Ib3a8cc9d28a096183f1d3dfd1941ea5fdc6a4aac
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Found by UBSan:
qrawfont.cpp:618:60: runtime error: load of misaligned address 0x2acee92a5569 for type 'const quint32', which requires 4 byte alignment
Fix by using MAKE_TAG(), like everywhere else, instead
of a load through a type-punned and misaligned pointer.
Change-Id: I52b88ca05a57f7d8c5e5bce953384de49514079b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
The existing code derived a helper class from QSqlResult and
overloaded two protected functions as public ones so the test
could call them after casting QSqlResults to that helper class.
Both the cast (which is a C-style cast, but with combined
static_cast and const_cast semanics) and the following member
function call are undefined behavior.
Fix by making the test class a friend of QSqlResult, and
dropping the casts.
Change-Id: I09de2e2b46976d01cfce25892aec6ad36881d3eb
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Left-shifts of negative values are undefined in C++. In particular,
they don't behave arithmetically.
Reported by UBSan:
qcosmeticstroker.cpp: 72:15: runtime error: left shift of negative value -14/-19/-32/-33/-34/-37/-38/-63/-64/-192/-384/-1280
qcosmeticstroker.cpp:444:20: runtime error: left shift of negative value -64
qcosmeticstroker.cpp:451:26: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:483:26: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:762:20: runtime error: left shift of negative value -64
qcosmeticstroker.cpp:774:26: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:813:47: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:839:20: runtime error: left shift of negative value -64
qcosmeticstroker.cpp:851:26: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:889:47: runtime error: left shift of negative value -1
qcosmeticstroker.cpp:932:27: runtime error: left shift of negative value -64
qcosmeticstroker.cpp:995:27: runtime error: left shift of negative value -3/-64
Fix by using ordinary multiplication instead, because negative
left-hand-side values don't look like they are an error.
Change-Id: Icbebd41f6ddd3dca4abd385585fc0f82064fe8b6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Tested on the Ubuntu 14.04 VM. The test didn't fail anymore with
2000 test rounds
Change-Id: Ic12c60e5ebf9c234358a6983bf87fa0a88d7886e
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@theqtcompany.com>
Show the widget when its initial size is 0 and the layout changes the
size during showing.
Task-number: QTBUG-51788
Change-Id: I3251ac27328f9715ff13d96e1b82fbf824d9e79d
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
At the moment, only checks the relational operators, where
it already found some which do not compile. In order to
simplify the test, the missing operators are supplied by
the test harness until they are fixed in the library.
Change-Id: Ief5daefa68f15de5f8e559c9378ed83b715b69ee
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Saves ~250b in text size on optimized GCC 5.3 Linux AMD64 builds.
Change-Id: Ic92c4ac1bb20230cfbb929bdf5c7f385d7b604e5
Reviewed-by: David Faure <david.faure@kdab.com>
Maintain virtual siblings list on screen deletion.
QCocoaIntegration::updateScreens() has a loop which
will delete all non-current QScreen objects using
QPlatformIntegration::destroyScreen().
destroyScreen() vill eventually call QWindowPrivate::
setTopLevelScreen() which accesses the virtual siblings
list for the deleted screen.
This can cause a stale pointer access if the virtual
screen list is not up to date, especially when disconnecting
two screens at the same time.
Change-Id: Ia6b9d01edf8e5eea25b64604a2b3b28b173125f7
Task-number: QTBUG-48275
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
There could be cases (mostly when compiled on old systems, since modern
openssl versions don't include such insecure ciphers) in which
defaultCiphers included a cipher that wasn't in the supported ciphers
list. With this patch we make sure that defaultCiphers is a subset of
supportedCiphers
Change-Id: I545ea21f5fd3a6ed13b366cdd56a1393233f9fc9
Reviewed-by: Richard J. Moore <rich@kde.org>
Since Qt 5.7 has dropped WinCE, including WEC2013, the patch for WinCE
is no longer needed.
The source code for the sqlite3 shell, shell.c, is not required for
building the qsqlite driver or anything else in Qt, so there is no
reason to keep bundling it with Qt sources.
Change-Id: Id0b03945451f9e843a0424c9fe510d79555717fc
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Gunnar Roth <gunnar.roth@gmx.net>
Replace Java-style iterators with STL-style iterators.
Java-style iterators have overhead.
Use std::stable_partition with erase() instead of using remove()
in a loop, with quadratic complexity.
Introduce local template homebrew any_of (analog of std::any_of from C++11)
to simplify current code. Also it's needed for following changes
in this class.
Change-Id: I2b11889ccc7630597c72aa20cdb266ae6ca2471a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
... when more than a return would be executed, to
prompt the compiler to move it out of the way of
the normal execution path.
Unexpectedly costs ~200b in text size on optimized
GCC 5.3 Linux AMD64 builds.
Change-Id: I0ebfb56af7c2262f64271a1b0ec46533e6000bc9
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
The SNI extension must not include the trailing dot, even though this
is legitimate for the host header.
Task-number: QTBUG-51821
Change-Id: Ib7a7d8b1f8f98bc99ae745b03d2b97e507adefaf
Reviewed-by: Daniel Molkentin (ownCloud) <danimo@owncloud.com>
Found by UBSan:
qnetworkrequest.cpp:1016:19: runtime error: load of value 4294967295, which is not a valid value for type 'KnownHeaders'
KnownHeaders does not contain a failure state, and no negative
values. -1 is therefore not a valid value for an object of type
KnownHeaders, so loading one is considered UB.
Fix by returning the result of parseHeaderName() as an int,
only casting to KnownHeaders after checking for the failure
case.
Change-Id: I6b165fe2b15c747344a9b2750bb753582c5bcbeb
Reviewed-by: Richard J. Moore <rich@kde.org>
Also print the failing type.
Sanity Bot complained about the spelling and Friedemann about
the grammar and missing type information in the output.
Change-Id: I7f38c56e569312e082e7b6baf9d556f5e7e40f80
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
The printf-style version of QDebug expands to a lot less code than the
std::ostream-style version. Of course, you pay in type safety (but
compilers warn about it these days), you cannot stream complex Qt
types and streaming QStrings is awkward, but in many cases you
actually improve on readability.
But the main reason is that something that's not supposed to be
executed under normal operation has no business bloating executable
code size.
This is not an attempt at converting all qWarnings() to printf-style,
only the low-hanging fruit.
In this first part, replace
qWarning() << ""
with
qWarning("...").
Had to fix broken qImDebug() definition. Instead of defining it as
a nullary macro in the QT_NO_DEBUG case and as a variadic macro in
the other, define it in both cases, as is customary, as a non-function
macro so that overload selection works without requiring variadic
macro support of the compiler.
Saves e.g. ~250b in text size in QtPrintSupport on optimized GCC 5.3
AMD64 builds.
Change-Id: Ie30fe2f7942115d5dbf99fff1750ae0d477c379f
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This change partially reverts 1bfc7f68 about QT_HAS_BUILTIN define
and undef in src/corelib/tools/qsimd_p.h.
This change is also squashed with "Fall back to c++11 standard
compiler flag for host builds" which is done by Peter Seiderer.
Conflicts:
mkspecs/features/default_post.prf
src/3rdparty/sqlite/0001-Fixing-the-SQLite3-build-for-WEC2013-again.patch
src/3rdparty/sqlite/sqlite3.c
src/corelib/tools/qsimd_p.h
src/gui/kernel/qevent.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface_p.h
src/plugins/bearer/blackberry/blackberry.pro
src/plugins/platforms/cocoa/qcocoasystemsettings.mm
src/plugins/platformthemes/gtk2/gtk2.pro
src/plugins/styles/bb10style/bb10style.pro
src/sql/drivers/sqlite2/qsql_sqlite2.cpp
tools/configure/configureapp.cpp
Task-number: QTBUG-51644
Done-with: Peter Seiderer <ps.report@gmx.net>
Change-Id: I6100d6ace31b2e8d41a95f0b5d5ebf8f1fd88b44
Add a command line tool that can either take a list of window ids and output
information on them using a verbose debug stream or embed foreign
windows using QWidget::createWindowContainer().
Task-number: QTBUG-41186
Change-Id: I14e436b5d08828f5b78b29e0701daeffe11367d3
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Introduce template helper function qSelectionIndexes().
Template argument is container. Now we have the same code for
QVector and QList.
Also it's needed for a follow-up change in this file:
add method QModelIndex QItemSelection::index().
Change-Id: I7f86a9b96e5feac9873cf0df7a1cbca74f9191ec
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
QReadWriteLock is supposed to be a better alternative to QMutex when there
are only a few writers but potentially lots of reads. However, in practice
the previous implementation was much slower, unless you really do a lot of
work with the lock for read and you have lots of contention.
Indeed, the previous implementation was locking a QMutex both for lock, and
unlock (making it already at least twice as slow as QMutex).
This new implementation brings QReadWriteLock back to the same level as QMutex:
- No memory allocations in the uncontended case (almost no overhead allowing to
create many of them in classes)
- Lock-free if there is no contention
Should support up to 2^31 concurrent readers on 64 bit platforms, and 2^28
on 32 bit platforms
Change-Id: Ifa2fc999075cbb971088f4ee8e6fde78ce262da3
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
A test should not write to its directory. Amends change
d0b54cede8.
Task-number: QTBUG-47176
Change-Id: If15258b4aed199792fab422b7ac1d74e22a9e322
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
Ideally all native NSWindows and NSViews owned by
QCocoaWindow should be deallocated during the QCocoaWindow
destructor. In reality this does not always happen
since Cocoa is free to hold references to the views
after Qt releases its reference.
We can help Cocoa clean up:
- Clear the first responder for the NSWindow under
the ~QCocoaWndow() autoreleasepool.
- Use an autoreleasepool to clean up temp objects
from [NSWindow orderFront:] immediately.
Together this makes the QNSView lifetime be contained
by the QCocoaWindow lifetime, at least for simple
QWindow usage. It also fixes the observed memory leak
reported in QTBUG-51766
Change-Id: Idd224f54ebd6f61f274461a204ff30c666b22768
Task-number: QTBUG-51766
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
I was surprised this compiled at all, since I thought
QT_NO_CAST_FROM_ASCII was in effect in Qt, but
apparently it isn't.
Change-Id: Id77743a2ca1b7f865960dc78d169584741f18d43
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
The printf-style version of QDebug expands to a lot less code than the
std::ostream-style version. Of course, you pay in type safety (but
compilers warn about it these days), you cannot stream complex Qt
types and streaming QStrings is awkward, but in many cases you
actually improve on readability.
But the main reason is that something that's not supposed to be
executed under normal operation has no business bloating executable
code size.
This is not an attempt at converting all qWarnings() to printf-style,
only the low-hanging fruit.
In this first part, replace
qWarning() << ""
with
qWarning("...").
Saves ~750b in text size on optimized GCC 5.3 AMD64 builds.
Change-Id: I8bf3e46cd5a6b2cae0ceb3e355a50f61925c63d3
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
DistanceField technique was not intended for rendering very large glyph.
In some case need the qEnvironmentVariable.
Change-Id: Ied11ed00f0c67bae3c92155e17721d8d2f224cca
Task-number: QTBUG-51714
Reviewed-by: Aram So <aram.so@lge.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
In addition to handling the pure rotation enforce a size change as well.
This way content is redrawn for the correct orientation.
It was done for Windows Phone 8.1 already, we only need to extent this
to Windows 10.
Task-number: QTBUG-50336
Change-Id: I6b3b964f44b631757ea856331c50f53c39ed9ec3
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
These types are held in QVariant, and QIBusAttribute is also
held in QVector. Now that they are no longer polymorphic,
they can be marked as movable.
Remove user-defined dtors to unlock the implicit move special
member functions, which I enforce in my local tree for all
Q_MOVABLE_TYPEs. Add std::move() when appending QIBusAttribute.
QVector has rvalue-push_back().
Change-Id: Ibb359939d5c11b5ef1f8ceced9a051cdde452dd5
Reviewed-by: Takao Fujiwara <takao.fujiwara1@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
These types don't inherit to be reused, they inherit to reuse.
Consequently, change the inheritance to private, remove the
virtual ~QIBusSerializable and rewrite the streaming operators
as member functions.
Remove the now-unused QIBusSerializable streaming operators and
meta-type registration.
Change-Id: Icf7a89174592ba62b39f73f0f016c8296cab5993
Reviewed-by: Takao Fujiwara <takao.fujiwara1@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Suppose a client connects while the QLocalServer is still in the loop
that calls addListener. The connection would SetEvent(eventHandle),
but every call to ConnectNamedPipe would ResetEvent(eventHandle).
Thus, the connection is never detected by the notifier on eventHandle.
Callers of addListener must check the connection state of every
listener to make sure that no client connected while setting up
listeners.
Task-number: QTBUG-49254
Change-Id: Ia961927ea76973708e6e3f73510695eb5d6a0e4c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Only two tests inside tst_qstatictext required private symbols, so
we can enable the rest on all builds.
Change-Id: Id222ba01d9676c40b6447c1526ee127fcc2090d3
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Use the newly introduced QSysInfo::machineHostName() to determine
the host name in the shared header, removing the need to link
against the winsocket library. All Windows-specific .pro sections
can then be removed.
Task-number: QTBUG-51673
Change-Id: Iba990b886b16addd210639871065abde6de96516
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
No longer try to load all files in the directory as a plugin
which can cause problems when for example installers move
files around.
[ChangeLog][QtCore][QFactoryLoader][Windows] QFactoryLoader now
filters potential plugins by the ".dll" suffix.
Task-number: QTBUG-31476
Change-Id: Ia19d6211c72765aaba0a5d06e6d3b501e8a40fff
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
In one code path the test checked for the emission of a readyRead()
signal without waiting for it.
This code path was never hit, neither on Windows nor on Unix platforms.
Change-Id: Ifbe464400a2a1ba8eab49bd60315289040e6bbde
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
QNetworkAccessManager::createRequest() had three checks relevant only
to GET and HEAD requests; rather than testing for this in each of the
cases, test for it once and skip all three if it fails. Tidied up the
residue of conditionals in the process.
Change-Id: I7baee8067a03afdc7cb0a77f1a50759dc4233843
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
QUrl::setScheme() parses and canonicalises the scheme, so that
scheme() always returns a lower-case string anyway; no need to
.toLower() it.
Change-Id: Ied00814b63f159386a42552dcf06346ee56f9f97
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
The platform has been removed in Qt 5.7.
Change-Id: Ie768b5ffbe60270c27b4a670dcf580ea361cb361
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Sometimes, in the .cpp, the declaration has the argument name in comments
because it is not used (instead of using Q_UNUSED). The old qdoc could
parse that, but once clang is used, these comments are not seen anymore.
So add the argument names to the headers. This is also good for things
like auto completion, which uses only the header to know what the
argument name is.
I grepped for " */)" and made sure all the functions that are documented
have the right arguments. I also added the name to all the function around
for consistency.
Change-Id: I1aaa37e25a1985f7f51653f047a1ac2633242b56
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
Factor out function to check on the pixel color that
outputs a verbose message on failure.
Change-Id: I2331fe45f35327d1ff8ae547a58d93a2e6fe9184
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Found by UBSan:
qmake/library/qmakeparser.cpp:278:33: runtime error: null pointer passed as argument 2, which is declared to never be null
Guard the call.
Change-Id: I99341ab439a511f366dae9344ddcc8727c33b9b6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>