diff --git a/doc/global/template/style/offline-simple.css b/doc/global/template/style/offline-simple.css index 84d206b2d0e..a805b924a30 100644 --- a/doc/global/template/style/offline-simple.css +++ b/doc/global/template/style/offline-simple.css @@ -1,4 +1,4 @@ -pre { +pre, .LegaleseLeft { background-color: #f0f0f0; font-family: Courier, monospace; font-weight: 600; diff --git a/doc/global/template/style/offline.css b/doc/global/template/style/offline.css index 6621b6bbcbf..e2081596c92 100644 --- a/doc/global/template/style/offline.css +++ b/doc/global/template/style/offline.css @@ -428,7 +428,7 @@ table styles /* table with border alternative colours*/ -table, pre { +table, pre, .LegaleseLeft { -moz-border-radius: 7px 7px 7px 7px; -webkit-border-radius: 7px 7px 7px 7px; border-radius: 7px 7px 7px 7px; @@ -485,6 +485,10 @@ table, pre { margin: 0px } +.LegaleseLeft { + font-family: monospace; + white-space: pre-wrap; +} /* table bodless & white*/ .borderless { @@ -547,7 +551,7 @@ ol.a > li{ text-align: left } -.cpp { +.cpp, .LegaleseLeft { display: block; margin: 10px; overflow: auto; diff --git a/doc/global/template/style/online.css b/doc/global/template/style/online.css index 080b45749d7..3c305f3ddbe 100644 --- a/doc/global/template/style/online.css +++ b/doc/global/template/style/online.css @@ -1370,7 +1370,7 @@ div.qt_commercial { border-top:5px solid #5caa15; margin-bottom:50px } -pre { +pre, .LegaleseLeft { background-color:#404244; color:#fff; display:block; @@ -1381,6 +1381,10 @@ pre { padding:25px; margin-top:0.75em } +.mainContent .LegaleseLeft p { + color:#fff; + white-space: pre-wrap +} .copy_text { background-color:#46a2da; color:#fff; diff --git a/examples/widgets/doc/src/calculator.qdoc b/examples/widgets/doc/src/calculator.qdoc index 5af52a75c9d..4ee1248e6c3 100644 --- a/examples/widgets/doc/src/calculator.qdoc +++ b/examples/widgets/doc/src/calculator.qdoc @@ -261,7 +261,7 @@ \snippet widgets/calculator/calculator.cpp 20 - Like in \c additiveOperatorClicked(), we start by handing any + Like in \c additiveOperatorClicked(), we start by handling any pending multiplicative and additive operators. Then we display \c sumSoFar and reset the variable to zero. Resetting the variable to zero is necessary to avoid counting the value twice. diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 00d5d248ed0..6aa850bf4e3 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -406,14 +406,21 @@ void NmakeMakefileGenerator::init() project->values("QMAKE_DISTCLEAN").append(tgt + ".lib"); } if (project->isActiveConfig("debug_info")) { - // Add the compiler's PDB file. - QString pdbfile = var("OBJECTS_DIR") + project->first("TARGET") + ".vc.pdb"; + QString pdbfile; + QString distPdbFile = tgt + ".pdb"; + if (project->isActiveConfig("staticlib")) { + // For static libraries, the compiler's pdb file and the dist pdb file are the same. + pdbfile = distPdbFile; + } else { + // Use $${TARGET}.vc.pdb in the OBJECTS_DIR for the compiler and + // $${TARGET}.pdb (the default) for the linker. + pdbfile = var("OBJECTS_DIR") + project->first("TARGET") + ".vc.pdb"; + } QString escapedPdbFile = escapeFilePath(pdbfile); project->values("QMAKE_CFLAGS").append("/Fd" + escapedPdbFile); project->values("QMAKE_CXXFLAGS").append("/Fd" + escapedPdbFile); project->values("QMAKE_CLEAN").append(pdbfile); - // Add the linker's PDB file to the distclean target. - project->values("QMAKE_DISTCLEAN").append(tgt + ".pdb"); + project->values("QMAKE_DISTCLEAN").append(distPdbFile); } if (project->isActiveConfig("debug")) { project->values("QMAKE_CLEAN").append(tgt + ".ilk"); diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp index 53772fe55aa..d09c7658d41 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp @@ -113,9 +113,9 @@ QSet dictionary = QtConcurrent::blockingFilteredReduced(strings, allLow //! [7] // keep only images with an alpha channel QList images = ...; -QFuture alphaImages = QtConcurrent::filter(strings, &QImage::hasAlphaChannel); +QFuture alphaImages = QtConcurrent::filter(images, &QImage::hasAlphaChannel); -// keep only gray scale images +// retrieve gray scale images QList images = ...; QFuture grayscaleImages = QtConcurrent::filtered(images, &QImage::isGrayscale); diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 5550dc21db6..112dda0d757 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1901,7 +1901,7 @@ void QFontEngineFT::unlockAlphaMapForGlyph() static inline bool is2dRotation(const QTransform &t) { return qFuzzyCompare(t.m11(), t.m22()) && qFuzzyCompare(t.m12(), -t.m21()) - && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), 1.0); + && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), qreal(1.0)); } QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 96021f45f48..a1f41a09292 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -847,7 +847,7 @@ bool QAbstractSocketPrivate::writeToSocket() const char *ptr = writeBuffer.readPointer(); // Attempt to write it all in one chunk. - qint64 written = socketEngine->write(ptr, nextSize); + qint64 written = nextSize ? socketEngine->write(ptr, nextSize) : Q_INT64_C(0); if (written < 0) { #if defined (QABSTRACTSOCKET_DEBUG) qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting." @@ -2501,7 +2501,7 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size) if (!d->isBuffered && d->socketType == TcpSocket && d->socketEngine && d->writeBuffer.isEmpty()) { // This code is for the new Unbuffered QTcpSocket use case - qint64 written = d->socketEngine->write(data, size); + qint64 written = size ? d->socketEngine->write(data, size) : Q_INT64_C(0); if (written < 0) { d->setError(d->socketEngine->error(), d->socketEngine->errorString()); } else if (written < size) { diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 9ba9d5317ed..0e7ab74e0be 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -853,6 +853,10 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, const Q /*! Writes a block of \a size bytes from \a data to the socket. Returns the number of bytes written, or -1 if an error occurred. + + Passing zero as the \a size parameter on a connected UDP socket + will send an empty datagram. For other socket types results are + unspecified. */ qint64 QNativeSocketEngine::write(const char *data, qint64 size) { diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 0319d4ca6d7..cc18c372a74 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -122,7 +122,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); - (void)dealloc { - [self restoreOriginalContentView]; + [mStolenContentView release]; [mColorPanel setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index dc7dfb788fb..2f4f80ad182 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -150,7 +150,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); - (void)dealloc { - [self restoreOriginalContentView]; + [mStolenContentView release]; [mFontPanel setDelegate:nil]; [[NSFontManager sharedFontManager] setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.h b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.h index 2d0101e8ae3..8d7cabf15b5 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.h +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.h @@ -43,6 +43,9 @@ #include Q_FORWARD_DECLARE_OBJC_CLASS(ALAsset); + +QT_BEGIN_NAMESPACE + class QIOSAssetData; class QIOSFileEngineAssetsLibrary : public QAbstractFileEngine @@ -78,5 +81,7 @@ private: ALAsset *loadAsset() const; }; +QT_END_NAMESPACE + #endif // QIOSFILEENGINEASSETSLIBRARY_H diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm index 560c54924ac..bea28972406 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + static QThreadStorage g_iteratorCurrentUrl; static QThreadStorage > g_assetDataCache; @@ -472,4 +474,6 @@ QAbstractFileEngine::Iterator *QIOSFileEngineAssetsLibrary::endEntryList() return 0; } +QT_END_NAMESPACE + #endif diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h index b71fa64460c..0397b20dfa3 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileenginefactory.h @@ -44,6 +44,8 @@ #include #include "qiosfileengineassetslibrary.h" +QT_BEGIN_NAMESPACE + class QIOSFileEngineFactory : public QAbstractFileEngineHandler { public: @@ -58,4 +60,6 @@ public: } }; +QT_END_NAMESPACE + #endif // QIOSFILEENGINEFACTORY_H diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp index b1d3691a109..06008e00d8c 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp @@ -58,7 +58,8 @@ #include #include -#include +// this is where EGL headers are pulled in, make sure it is last +#include "qminimaleglscreen.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.h b/src/plugins/platforms/minimalegl/qminimaleglintegration.h index 020fa09443a..529e89f85a6 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.h +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.h @@ -40,8 +40,6 @@ #ifndef QMINIMALEGLINTEGRATION_H #define QMINIMALEGLINTEGRATION_H -#include "qminimaleglscreen.h" - #include #include diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.h b/src/plugins/platforms/minimalegl/qminimaleglwindow.h index 5c2955f7837..b8bfd6c8d2d 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglwindow.h +++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.h @@ -41,7 +41,6 @@ #define QMINIMALEGLWINDOW_H #include "qminimaleglintegration.h" -#include "qminimaleglscreen.h" #include diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 1e00da52eb3..dd99e674ec7 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -102,6 +102,18 @@ "features": [ "disable_desktopgl", "disable_d3d11", "disable_d3d9" ] + }, + { + "id": 9, + "description": "Intel 945 crash (QTBUG-40991)", + "vendor_id": "0x8086", + "device_id": [ "0x27A2" ], + "os": { + "type": "win" + }, + "features": [ + "disable_desktopgl" + ] } ] } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 19b7238a70b..4426a6d4157 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -401,9 +401,6 @@ public: const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore); - - QPainter *beginSharedPainter(); - bool endSharedPainter(); #ifndef QT_NO_GRAPHICSVIEW static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin); #endif diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index ac8902c9e67..185a66731bf 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -112,6 +112,7 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack if (widget != tlw) offset += widget->mapTo(tlw, QPoint()); + QRegion effectiveRegion = region; #ifndef QT_NO_OPENGL const bool compositionWasActive = widget->d_func()->renderToTextureComposeActive; if (!widgetTextures) { @@ -125,6 +126,11 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack } else { widget->d_func()->renderToTextureComposeActive = true; } + // When changing the composition status, make sure the dirty region covers + // the entire widget. Just having e.g. the shown/hidden render-to-texture + // widget's area marked as dirty is incorrect when changing flush paths. + if (compositionWasActive != widget->d_func()->renderToTextureComposeActive) + effectiveRegion = widget->rect(); // re-test since we may have been forced to this path via the dummy texture list above if (widgetTextures) { @@ -136,12 +142,12 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion ®ion, QBack const bool translucentBackground = widget->testAttribute(Qt::WA_TranslucentBackground); // Use the tlw's context, not widget's. The difference is important with native child // widgets where tlw != widget. - backingStore->handle()->composeAndFlush(widget->windowHandle(), region, offset, widgetTextures, + backingStore->handle()->composeAndFlush(widget->windowHandle(), effectiveRegion, offset, widgetTextures, tlw->d_func()->shareContext(), translucentBackground); widget->window()->d_func()->sendComposeStatus(widget->window(), true); } else #endif - backingStore->flush(region, widget->windowHandle(), offset); + backingStore->flush(effectiveRegion, widget->windowHandle(), offset); } #ifndef QT_NO_PAINT_DEBUG diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 9fb18f63e89..1aa53de4867 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -811,7 +811,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) bool translucentToplevel = false; const QPaintDevice *paintDevice = painter->device(); - const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatio() : 1; + const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatioF() : qreal(1); if (paintDevice->devType() == QInternal::Widget) { const QWidget *window = static_cast(paintDevice)->window(); translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground); @@ -840,28 +840,28 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); const bool result = dc - ? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio)) - : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); + ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio) + : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio); painter->restore(); return result; } -static inline QRect scaleRect(const QRect &r, int factor) +static inline QRectF scaleRect(const QRectF &r, qreal factor) { return r.isValid() && factor > 1 - ? QRect(r.topLeft() * factor, r.size() * factor) + ? QRectF(r.topLeft() * factor, r.size() * factor) : r; } -static QRegion scaleRegion(const QRegion ®ion, int factor) +static QRegion scaleRegion(const QRegion ®ion, qreal factor) { - if (region.isEmpty() || factor == 1) + if (region.isEmpty() || qFuzzyCompare(factor, qreal(1))) return region; if (region.rectCount() == 1) - return QRegion(scaleRect(region.boundingRect(), factor)); + return QRegion(scaleRect(QRectF(region.boundingRect()), factor).toRect()); QRegion result; foreach (const QRect &rect, region.rects()) - result += QRect(rect.topLeft() * factor, rect.size() * factor); + result += QRectF(QPointF(rect.topLeft()) * factor, QSizeF(rect.size() * factor)).toRect(); return result; } @@ -870,13 +870,12 @@ static QRegion scaleRegion(const QRegion ®ion, int factor) Do not use this if you need to perform other transformations on the resulting data. */ -bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QPoint redirectionDelta(int(painter->deviceMatrix().dx()), - int(painter->deviceMatrix().dy())); - QRect area = scaleRect(themeData.rect, additionalDevicePixelRatio).translated(redirectionDelta); + const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy()); + const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect(); QRegion sysRgn = painter->paintEngine()->systemClip(); if (sysRgn.isEmpty()) @@ -884,7 +883,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa else sysRgn &= area; if (painter->hasClipping()) - sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta); + sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta.toPoint()); HRGN hrgn = qt_hrgn_from_qregion(sysRgn); SelectClipRgn(dc, hrgn); @@ -956,15 +955,16 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa engine). */ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData, - int additionalDevicePixelRatio) + qreal additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - QRect rect = scaleRect(themeData.rect, additionalDevicePixelRatio); + QRectF rectF = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio); if ((themeData.rotate + 90) % 180 == 0) { // Catch 90,270,etc.. degree flips. - rect = QRect(0, 0, rect.height(), rect.width()); + rectF = QRectF(0, 0, rectF.height(), rectF.width()); } - rect.moveTo(0,0); + rectF.moveTo(0, 0); + QRect rect = rectF.toRect(); int partId = themeData.partId; int stateId = themeData.stateId; int w = rect.width(); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 8ee4d1a6417..2838ee93e09 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -394,8 +394,8 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); - bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); - bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, qreal aditionalDevicePixelRatio); + bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 5f7cfec5afe..b8472e025ef 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -670,8 +670,10 @@ QWidget *QMainWindow::takeCentralWidget() { Q_D(QMainWindow); QWidget *oldcentralwidget = d->layout->centralWidget(); - oldcentralwidget->setParent(0); - d->layout->setCentralWidget(0); + if (oldcentralwidget) { + oldcentralwidget->setParent(0); + d->layout->setCentralWidget(0); + } return oldcentralwidget; } diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 5bd26c632cc..6ee5f76c6ab 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -859,6 +859,10 @@ void tst_QMainWindow::takeCentralWidget() { QVERIFY(!mw.centralWidget()); + // verify that we don't crash when trying to take a non-set + // central widget but just return a null pointer instead + QVERIFY(!mw.takeCentralWidget()); + mw.setCentralWidget(w1); QWidget *oldCentralWidget = mw.takeCentralWidget(); diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index bf82f141595..8f18f3c489d 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -150,25 +151,23 @@ QString Environment::gccVersion() QString Environment::msvcVersion() { int returnValue = 0; - // Extract version from standard error output of "cl /?" - const QString command = QFile::decodeName(qgetenv("ComSpec")) - + QLatin1String(" /c ") + QLatin1String(compilerInfo(CC_MSVC2015)->executable) - + QLatin1String(" /? 2>&1"); - SetEnvironmentVariable(L"CL", NULL); // May contain /nologo, which suppresses the version. - QString version = execute(command, &returnValue); - if (returnValue != 0) { - cout << "Could not get cl version" << returnValue << qPrintable(version) << '\n';; - version.clear(); - } else { - QRegExp versionRegexp(QStringLiteral("^.*\\b(\\d{2,2}\\.\\d{2,2}\\.\\d{5,5})\\b.*$")); - Q_ASSERT(versionRegexp.isValid()); - if (versionRegexp.exactMatch(version)) { - version = versionRegexp.cap(1); - } else { - cout << "Unable to determine cl version from the output of \"" - << qPrintable(command) << "\"\n"; - } + QString tempSourceName; + { // QTemporaryFile needs to go out of scope, otherwise cl.exe refuses to open it. + QTemporaryFile tempSource(QDir::tempPath() + QLatin1String("/XXXXXX.cpp")); + tempSource.setAutoRemove(false); + if (!tempSource.open()) + return QString(); + tempSource.write("_MSC_FULL_VER\n"); + tempSourceName = tempSource.fileName(); } + QString version = execute(QLatin1String("cl /nologo /EP \"") + + QDir::toNativeSeparators(tempSourceName) + QLatin1Char('"'), + &returnValue).trimmed(); + QFile::remove(tempSourceName); + if (returnValue || version.size() < 9 || !version.at(0).isDigit()) + return QString(); + version.insert(4, QLatin1Char('.')); + version.insert(2, QLatin1Char('.')); return version; }