diff options
25 files changed, 302 insertions, 73 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl index 0c10ccbe14..97288c5a3e 100755 --- a/bin/syncqt.pl +++ b/bin/syncqt.pl @@ -231,7 +231,7 @@ sub classNames { } if($line) { $line =~ s,//.*$,,; #remove c++ comments - $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro + $line .= ";" if($line =~ m/^Q_[A-Z_0-9]*\(.*\)[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE(_[A-Z]+)*[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro @@ -362,7 +362,7 @@ sub check_header { $include = 0; } if ($include && $public_header) { - print STDERR "$lib: ERROR: $iheader includes private header $include\n" if ($include =~ /_p.h$/); + print STDERR "$lib: ERROR: $iheader includes private header $include\n" if ($include =~ /_p\.h$/); for my $trylib (keys(%modules)) { if (-e "$out_basedir/include/$trylib/$include") { print STDERR "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n"; @@ -989,7 +989,7 @@ foreach my $lib (@modules_to_sync) { my $header_dirname = ""; foreach my $header (@headers) { my $shadow = ($header =~ s/^\*//); - $header = 0 if($header =~ /^ui_.*.h/); + $header = 0 if ($header =~ /^ui_.*\.h$/); foreach (@ignore_headers) { $header = 0 if($header eq $_); } @@ -1001,7 +1001,7 @@ foreach my $lib (@modules_to_sync) { if(isQpaHeader($public_header)) { $public_header = 0; $qpa_header = 1; - } elsif($allheadersprivate || $thisprivate || $public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { + } elsif ($allheadersprivate || $thisprivate || $public_header =~ /_p(ch)?\.h$/) { $public_header = 0; } else { foreach (@ignore_for_master_contents) { diff --git a/dist/changes-5.6.2 b/dist/changes-5.6.2 index 7b62a018f3..af02f2a6b9 100644 --- a/dist/changes-5.6.2 +++ b/dist/changes-5.6.2 @@ -41,6 +41,11 @@ information about a particular change. * Library * ****************************************************************************** +General +------- + + - [QTBUG-45291] Qt headers are now gcc -Wzero-as-null-pointer-constant clean. + QtCore ------ @@ -335,5 +340,47 @@ Windows moc --- + - [QTBUG-53441] Fixed crash on file ending with a backslash followed by carriage return + +configure & build system +------------------------ + + - [QTBUG-35886][QTBUG-51417] Fixed Fontconfig vs. system FreeType + configuration. + - [QTBUG-43784][X11] Fixed detection of GLX with -qt-xcb. + - [QTBUG-52951] Fixed dynamic library support detection for platforms + without libdl. + - [QTBUG-53038] Fixed running of configure tests outside qtbase when + cross compiling on Windows (for example for Android). + - [QTBUG-53312] The flags supplied by the configure -D/-I/-L/-l options + are now applied after Qt's own flags. This helps in some cases when + the provided paths contain files which conflict with the Qt build. + - [QTBUG-55011][Unix] Fixed -no-pkg-config being ignored by some + configure tests, which led to build failures later on. + - Fixed configure tests outside qtbase when $MAKEFLAGS contains the + -i flag. + - [Android] Some unused plugins are not built anymore. + - [MinGW] Added support for -separate-debug-info. + - [Unix] Added configure -no-opengles3 option. + - [Unix] Fixed MySQL detection/use on RHEL 6.6. + +qmake +----- + + - [QTBUG-41830] Fixed nested custom functions inheriting their callers' + arguments. + - [QTBUG-53895][MSVC] Started using separate PDB files for compiling + and linking. + - [QTBUG-54036][Darwin] Fixed installation of debug symbols. + - [QTBUG-54550] Fixed access to freed memory in $$absolute_path(). + - [QTBUG-55183][nmake] _WINDLL is now automatically defined when building + a DLL, consistently with Visual Studio. + - [QTBUG-55649][QTBUG-55915][Xcode] Fixed support for Xcode 8. + - Fixed several cases where the error() function would not abort qmake. + - Interrupting a command run via system() will now abort qmake as well. + - The packagesExist() function will now warn when used when Qt was + configured with -no-pkg-config. + - [Android] The default compiler flags were adjusted to match newer + NDK versions. diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 4134513210..a7c8aae989 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -522,16 +522,26 @@ bool QOpenGLShader::compileSourceCode(const char *source) QVarLengthArray<const char *, 5> sourceChunks; QVarLengthArray<GLint, 5> sourceChunkLengths; + QOpenGLContext *ctx = QOpenGLContext::currentContext(); if (versionDirectivePosition.hasPosition()) { - // Append source up to #version directive + // Append source up to and including the #version directive sourceChunks.append(source); sourceChunkLengths.append(GLint(versionDirectivePosition.position)); + } else { + // QTBUG-55733: Intel on Windows with Compatibility profile requires a #version always + if (ctx->format().profile() == QSurfaceFormat::CompatibilityProfile) { + const char *vendor = reinterpret_cast<const char *>(ctx->functions()->glGetString(GL_VENDOR)); + if (vendor && !strcmp(vendor, "Intel")) { + static const char version110[] = "#version 110\n"; + sourceChunks.append(version110); + sourceChunkLengths.append(GLint(sizeof(version110)) - 1); + } + } } // The precision qualifiers are useful on OpenGL/ES systems, // but usually not present on desktop systems. - QOpenGLContext *ctx = QOpenGLContext::currentContext(); const QSurfaceFormat currentSurfaceFormat = ctx->format(); QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(QOpenGLContext::currentContext()); if (currentSurfaceFormat.renderableType() == QSurfaceFormat::OpenGL diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index da53ccfe70..53813c7f9c 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -404,6 +404,9 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) if (seenIndexes.contains(ifindex)) continue; + seenInterfaces.insert(name); + seenIndexes.append(ifindex); + QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; interfaces << iface; iface->name = name; diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index fd82d53fa8..7442bbf1d5 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -652,7 +652,7 @@ void QSslSocketBackendPrivate::transmit() if (connectionEncrypted) { QVarLengthArray<char, 4096> data; - while (context) { + while (context && (!readBufferMaxSize || buffer.size() < readBufferMaxSize)) { size_t readBytes = 0; data.resize(4096); const OSStatus err = SSLRead(context, data.data(), data.size(), &readBytes); diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 274785660b..9e7da2835b 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1868,12 +1868,14 @@ void QColorDialogPrivate::retranslateStrings() bool QColorDialogPrivate::canBeNativeDialog() const { - Q_Q(const QColorDialog); + // Don't use Q_Q here! This function is called from ~QDialog, + // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()). + const QDialog * const q = static_cast<const QDialog*>(q_ptr); if (nativeDialogInUse) return true; if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) || q->testAttribute(Qt::WA_DontShowOnScreen) - || (q->options() & QColorDialog::DontUseNativeDialog)) { + || (options->options() & QColorDialog::DontUseNativeDialog)) { return false; } diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 814a203d1c..fc360d8381 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -700,12 +700,14 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files) bool QFileDialogPrivate::canBeNativeDialog() const { - Q_Q(const QFileDialog); + // Don't use Q_Q here! This function is called from ~QDialog, + // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()). + const QDialog * const q = static_cast<const QDialog*>(q_ptr); if (nativeDialogInUse) return true; if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) || q->testAttribute(Qt::WA_DontShowOnScreen) - || (q->options() & QFileDialog::DontUseNativeDialog)) { + || (options->options() & QFileDialog::DontUseNativeDialog)) { return false; } diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 4c01219d87..6e10d18e11 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -2096,7 +2096,7 @@ QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints) void QGraphicsAnchorLayoutPrivate::calculateGraphs( QGraphicsAnchorLayoutPrivate::Orientation orientation) { -#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) +#if defined(QT_DEBUG) || defined(QT_BUILD_INTERNAL) lastCalculationUsedSimplex[orientation] = false; #endif @@ -2249,7 +2249,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum; } -#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) +#if defined(QT_DEBUG) || defined(QT_BUILD_INTERNAL) lastCalculationUsedSimplex[orientation] = needsSimplex; #endif diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index c284e6ace3..7f50b3fda4 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -578,7 +578,7 @@ public: bool graphHasConflicts[2]; QSet<QGraphicsLayoutItem *> m_floatItems[2]; -#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT) +#if defined(QT_DEBUG) || defined(QT_BUILD_INTERNAL) bool lastCalculationUsedSimplex[2]; #endif diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 6a4f740b84..15edb15619 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -717,10 +717,11 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) ++it; } - QGraphicsObject *dummy = item->toGraphicsObject(); - cachedTargetItems.removeOne(dummy); - cachedItemGestures.remove(dummy); - cachedAlreadyDeliveredGestures.remove(dummy); + if (QGraphicsObject *dummy = item->toGraphicsObject()) { + cachedTargetItems.removeOne(dummy); + cachedItemGestures.remove(dummy); + cachedAlreadyDeliveredGestures.remove(dummy); + } foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys()) ungrabGesture(item, gesture); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4dc04c5fa1..1b77d74cd0 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3174,11 +3174,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) key->accept(); else key->ignore(); - res = d->notify_helper(receiver, e); QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0; #ifndef QT_NO_GRAPHICSVIEW QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0; #endif + res = d->notify_helper(receiver, e); if ((res && key->isAccepted()) /* diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 240f525722..7f30a78848 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -546,7 +546,7 @@ void QLayout::invalidate() update(); } -static bool removeWidgetRecursively(QLayoutItem *li, QWidget *w) +static bool removeWidgetRecursively(QLayoutItem *li, QObject *w) { QLayout *lay = li->layout(); if (!lay) @@ -609,12 +609,11 @@ void QLayout::widgetEvent(QEvent *e) { QChildEvent *c = (QChildEvent *)e; if (c->child()->isWidgetType()) { - QWidget *w = (QWidget *)c->child(); #ifndef QT_NO_MENUBAR - if (w == d->menubar) + if (c->child() == d->menubar) d->menubar = 0; #endif - removeWidgetRecursively(this, w); + removeWidgetRecursively(this, c->child()); } } break; diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 006b3e8588..d9c1c524d7 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -41,7 +41,7 @@ #include "qlayout_p.h" #include <qlist.h> -#include <qwidget.h> +#include "private/qwidget_p.h" #include "private/qlayoutengine_p.h" QT_BEGIN_NAMESPACE @@ -251,14 +251,10 @@ QLayoutItem *QStackedLayout::itemAt(int index) const // Code that enables proper handling of the case that takeAt() is // called somewhere inside QObject destructor (can't call hide() // on the object then) - -class QtFriendlyLayoutWidget : public QWidget +static bool qt_wasDeleted(const QWidget *w) { -public: - inline bool wasDeleted() const { return d_ptr->wasDeleted; } -}; - -static bool qt_wasDeleted(const QWidget *w) { return static_cast<const QtFriendlyLayoutWidget*>(w)->wasDeleted(); } + return QWidgetPrivate::get(w)->wasDeleted; +} /*! diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index 68ac874b59..759c9864a6 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -508,45 +508,46 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; } - const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); - const QMouseEvent *me = static_cast<const QMouseEvent *>(event); -#ifndef QT_NO_GRAPHICSVIEW - const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); -#endif - enum { TapRadius = 40 }; switch (event->type()) { #ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMousePress: + case QEvent::GraphicsSceneMousePress: { + const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); d->position = gsme->screenPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout + } #endif - case QEvent::MouseButtonPress: + case QEvent::MouseButtonPress: { + const QMouseEvent *me = static_cast<const QMouseEvent *>(event); d->position = me->globalPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout - case QEvent::TouchBegin: + } + case QEvent::TouchBegin: { + const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); d->position = ev->touchPoints().at(0).startScreenPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout + } #ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMouseRelease: #endif case QEvent::MouseButtonRelease: case QEvent::TouchEnd: return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state - case QEvent::TouchUpdate: + case QEvent::TouchUpdate: { + const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); if (d->timerId && ev->touchPoints().size() == 1) { QTouchEvent::TouchPoint p = ev->touchPoints().at(0); QPoint delta = p.pos().toPoint() - p.startPos().toPoint(); @@ -554,7 +555,9 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, return QGestureRecognizer::MayBeGesture; } return QGestureRecognizer::CancelGesture; + } case QEvent::MouseMove: { + const QMouseEvent *me = static_cast<const QMouseEvent *>(event); QPoint delta = me->globalPos() - d->position.toPoint(); if (d->timerId && delta.manhattanLength() <= TapRadius) return QGestureRecognizer::MayBeGesture; @@ -562,6 +565,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, } #ifndef QT_NO_GRAPHICSVIEW case QEvent::GraphicsSceneMouseMove: { + const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); QPoint delta = gsme->screenPos() - d->position.toPoint(); if (d->timerId && delta.manhattanLength() <= TapRadius) return QGestureRecognizer::MayBeGesture; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 293dafd932..b2973349e5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5231,8 +5231,10 @@ static void sendResizeEvents(QWidget *target) const QObjectList children = target->children(); for (int i = 0; i < children.size(); ++i) { + if (!children.at(i)->isWidgetType()) + continue; QWidget *child = static_cast<QWidget*>(children.at(i)); - if (child->isWidgetType() && !child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent)) + if (!child->isWindow() && child->testAttribute(Qt::WA_PendingResizeEvent)) sendResizeEvents(child); } } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index f44c0aff21..19b7238a70 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -329,6 +329,7 @@ public: ~QWidgetPrivate(); static QWidgetPrivate *get(QWidget *w) { return w->d_func(); } + static const QWidgetPrivate *get(const QWidget *w) { return w->d_func(); } QWExtra *extraData() const; QTLWExtra *topData() const; diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index b168c98410..54094de765 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2394,18 +2394,21 @@ void QDateTimeEditPrivate::init(const QVariant &var) switch (var.type()) { case QVariant::Date: value = QDateTime(var.toDate(), QDATETIMEEDIT_TIME_MIN); + updateTimeSpec(); q->setDisplayFormat(defaultDateFormat); if (sectionNodes.isEmpty()) // ### safeguard for broken locale q->setDisplayFormat(QLatin1String("dd/MM/yyyy")); break; case QVariant::DateTime: value = var; + updateTimeSpec(); q->setDisplayFormat(defaultDateTimeFormat); if (sectionNodes.isEmpty()) // ### safeguard for broken locale q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss")); break; case QVariant::Time: value = QDateTime(QDATETIMEEDIT_DATE_INITIAL, var.toTime()); + updateTimeSpec(); q->setDisplayFormat(defaultTimeFormat); if (sectionNodes.isEmpty()) // ### safeguard for broken locale q->setDisplayFormat(QLatin1String("hh:mm:ss")); @@ -2418,7 +2421,6 @@ void QDateTimeEditPrivate::init(const QVariant &var) if (QApplication::keypadNavigationEnabled()) q->setCalendarPopup(true); #endif - updateTimeSpec(); q->setInputMethodHints(Qt::ImhPreferNumbers); setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem); } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index b605b89f34..333305d603 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -6532,6 +6532,29 @@ signals: CountedStruct mySignal(const CountedStruct &s1, CountedStruct s2); }; +class CountedExceptionThrower : public QObject +{ + Q_OBJECT + +public: + explicit CountedExceptionThrower(bool throwException, QObject *parent = Q_NULLPTR) + : QObject(parent) + { + if (throwException) + throw ObjectException(); + ++counter; + } + + ~CountedExceptionThrower() + { + --counter; + } + + static int counter; +}; + +int CountedExceptionThrower::counter = 0; + void tst_QObject::exceptions() { #ifndef QT_NO_EXCEPTIONS @@ -6593,6 +6616,59 @@ void tst_QObject::exceptions() } QCOMPARE(countedStructObjectsCount, 0); + // Child object reaping in case of exceptions thrown by constructors + { + QCOMPARE(CountedExceptionThrower::counter, 0); + + try { + class ParentObject : public QObject { + public: + explicit ParentObject(QObject *parent = Q_NULLPTR) + : QObject(parent) + { + new CountedExceptionThrower(false, this); + new CountedExceptionThrower(false, this); + new CountedExceptionThrower(true, this); // throws + } + }; + + ParentObject p; + QFAIL("Exception not thrown"); + } catch (const ObjectException &) { + } catch (...) { + QFAIL("Wrong exception thrown"); + } + + QCOMPARE(CountedExceptionThrower::counter, 0); + + try { + QObject o; + new CountedExceptionThrower(false, &o); + new CountedExceptionThrower(false, &o); + new CountedExceptionThrower(true, &o); // throws + + QFAIL("Exception not thrown"); + } catch (const ObjectException &) { + } catch (...) { + QFAIL("Wrong exception thrown"); + } + + QCOMPARE(CountedExceptionThrower::counter, 0); + + try { + QObject o; + CountedExceptionThrower c1(false, &o); + CountedExceptionThrower c2(false, &o); + CountedExceptionThrower c3(true, &o); // throws + + QFAIL("Exception not thrown"); + } catch (const ObjectException &) { + } catch (...) { + QFAIL("Wrong exception thrown"); + } + + QCOMPARE(CountedExceptionThrower::counter, 0); + } #else QSKIP("Needs exceptions"); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index f36528f17d..00c3a41d88 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -223,6 +223,7 @@ private slots: void ecdhServer(); void verifyClientCertificate_data(); void verifyClientCertificate(); + void readBufferMaxSize(); #ifndef QT_NO_OPENSSL void simplePskConnect_data(); @@ -3037,6 +3038,68 @@ void tst_QSslSocket::verifyClientCertificate() QCOMPARE(client->isEncrypted(), works); } +void tst_QSslSocket::readBufferMaxSize() +{ +#ifdef QT_SECURETRANSPORT + // QTBUG-55170: + // SecureTransport back-end was ignoring read-buffer + // size limit, resulting (potentially) in a constantly + // growing internal buffer. + // The test's logic is: we set a small read buffer size on a client + // socket (to some ridiculously small value), server sends us + // a bunch of bytes , we ignore readReady signal so + // that socket's internal buffer size stays + // >= readBufferMaxSize, we wait for a quite long time + // (which previously would be enough to read completely) + // and we check socket's bytesAvaiable to be less than sent. + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer server; + QVERIFY(server.listen()); + + QEventLoop loop; + + QSslSocketPtr client(new QSslSocket); + socket = client.data(); + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); + + client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), + server.serverPort()); + + // Wait for 'encrypted' first: + QTimer::singleShot(5000, &loop, SLOT(quit())); + loop.exec(); + + QCOMPARE(client->state(), QAbstractSocket::ConnectedState); + QCOMPARE(client->mode(), QSslSocket::SslClientMode); + + client->setReadBufferSize(10); + const QByteArray message(int(0xffff), 'a'); + server.socket->write(message); + + QTimer::singleShot(5000, &loop, SLOT(quit())); + loop.exec(); + + int readSoFar = client->bytesAvailable(); + QVERIFY(readSoFar > 0 && readSoFar < message.size()); + // Now, let's check that we still can read the rest of it: + QCOMPARE(client->readAll().size(), readSoFar); + + client->setReadBufferSize(0); + + QTimer::singleShot(1500, &loop, SLOT(quit())); + loop.exec(); + + QCOMPARE(client->bytesAvailable() + readSoFar, message.size()); +#else + // Not needed, QSslSocket works correctly with other back-ends. +#endif +} + void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, as it has some side effects { // used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265 diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 3f35712489..81c5926f3a 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -71,6 +71,10 @@ private slots: void testRasterRGB32(); void testRasterRGB16_data(); void testRasterRGB16(); + void testRasterARGB8565PM_data(); + void testRasterARGB8565PM(); + void testRasterGrayscale8_data(); + void testRasterGrayscale8(); #ifndef QT_NO_OPENGL void testOpenGL_data(); @@ -150,6 +154,28 @@ void tst_Lancelot::testRasterRGB16() } +void tst_Lancelot::testRasterARGB8565PM_data() +{ + setupTestSuite(); +} + +void tst_Lancelot::testRasterARGB8565PM() +{ + runTestSuite(Raster, QImage::Format_ARGB8565_Premultiplied); +} + + +void tst_Lancelot::testRasterGrayscale8_data() +{ + setupTestSuite(); +} + +void tst_Lancelot::testRasterGrayscale8() +{ + runTestSuite(Raster, QImage::Format_Grayscale8); +} + + #ifndef QT_NO_OPENGL bool tst_Lancelot::checkSystemGLSupport() { diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index b7e8cded7a..ab9729342c 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1755,25 +1755,6 @@ void tst_QApplication::focusOut() QTest::qWait(2000); } -class SpontaneousEvent -{ - Q_GADGET - QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - Q_ENUMS(Type) -public: - enum Type { - Void - }; - - virtual ~SpontaneousEvent() {} - - QEventPrivate *d; - ushort t; - - ushort posted : 1; - ushort spont : 1; -}; - void tst_QApplication::focusMouseClick() { int argc = 1; @@ -1791,14 +1772,14 @@ void tst_QApplication::focusMouseClick() // now send a mouse button press event and check what happens with the focus // it should be given to the parent widget QMouseEvent ev(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QSpontaneKeyEvent::setSpontaneous(&ev); QVERIFY(ev.spontaneous()); qApp->notify(&w2, &ev); QCOMPARE(QApplication::focusWidget(), &w); // then we give the inner widget strong focus -> it should get focus w2.setFocusPolicy(Qt::StrongFocus); - reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QSpontaneKeyEvent::setSpontaneous(&ev); QVERIFY(ev.spontaneous()); qApp->notify(&w2, &ev); QTRY_COMPARE(QApplication::focusWidget(), &w2); @@ -1806,7 +1787,7 @@ void tst_QApplication::focusMouseClick() // now back to tab focus and click again (it already had focus) -> focus should stay // (focus was revoked as of QTBUG-34042) w2.setFocusPolicy(Qt::TabFocus); - reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QSpontaneKeyEvent::setSpontaneous(&ev); QVERIFY(ev.spontaneous()); qApp->notify(&w2, &ev); QCOMPARE(QApplication::focusWidget(), &w2); diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index e87598617a..0b35db1b5f 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -183,7 +183,7 @@ void tst_QBoxLayout::sizeConstraints() window.show(); QTest::qWaitForWindowExposed(&window); QSize sh = window.sizeHint(); - lay->takeAt(1); + delete lay->takeAt(1); QVERIFY(sh.width() >= window.sizeHint().width() && sh.height() >= window.sizeHint().height()); @@ -512,7 +512,7 @@ void tst_QBoxLayout::replaceWidget() QCOMPARE(boxLayout->indexOf(replaceFrom), 1); QCOMPARE(boxLayout->indexOf(replaceTo), -1); - boxLayout->replaceWidget(replaceFrom, replaceTo); + delete boxLayout->replaceWidget(replaceFrom, replaceTo); QCOMPARE(boxLayout->indexOf(replaceFrom), -1); QCOMPARE(boxLayout->indexOf(replaceTo), 1); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 07dcfca28f..e5da83ed37 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -348,6 +348,8 @@ void tst_QGridLayout::setMinAndMaxSize() layout.removeItem(spacer); + delete spacer; + spacer = Q_NULLPTR; rightChild.hide(); QApplication::sendPostedEvents(0, 0); @@ -1598,10 +1600,10 @@ void tst_QGridLayout::contentsRect() void tst_QGridLayout::distributeMultiCell() { QWidget w; - Qt42Style *style = new Qt42Style(); - style->spacing = 9; + Qt42Style style; + style.spacing = 9; - w.setStyle(style); + w.setStyle(&style); QGridLayout grid; w.setLayout(&grid); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index bbff9f0e50..272e6ef02f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5130,7 +5130,8 @@ void tst_QWidget::moveChild() ColorWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint); // prevent custom styles - parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); + const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows"))); + parent.setStyle(style.data()); ColorWidget child(&parent, Qt::Widget, Qt::blue); #ifndef Q_OS_WINCE @@ -5179,7 +5180,8 @@ void tst_QWidget::showAndMoveChild() QSKIP("Wayland: This fails. Figure out why."); QWidget parent(0, Qt::Window | Qt::WindowStaysOnTopHint); // prevent custom styles - parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); + const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows"))); + parent.setStyle(style.data()); QDesktopWidget desktop; QRect desktopDimensions = desktop.availableGeometry(&parent); @@ -6675,7 +6677,9 @@ void tst_QWidget::renderWithPainter() { QWidget widget(0, Qt::Tool); // prevent custom styles - widget.setStyle(QStyleFactory::create(QLatin1String("Windows"))); + + const QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Windows"))); + widget.setStyle(style.data()); widget.show(); widget.resize(70, 50); widget.setAutoFillBackground(true); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 831d7257ba..31eb05a957 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -245,6 +245,7 @@ private slots: void timeSpec_data(); void timeSpec(); void timeSpecBug(); + void timeSpecInit(); void monthEdgeCase(); void setLocale(); @@ -3200,6 +3201,13 @@ void tst_QDateTimeEdit::timeSpecBug() QCOMPARE(oldText, testWidget->text()); } +void tst_QDateTimeEdit::timeSpecInit() +{ + QDateTime utc(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC); + QDateTimeEdit widget(utc); + QCOMPARE(widget.dateTime(), utc); +} + void tst_QDateTimeEdit::cachedDayTest() { testWidget->setDisplayFormat("MM/dd"); |