Merge remote-tracking branch 'origin/5.12' into 5.13

Change-Id: I2bf3b4ceb79364330eae4cbf3cdee9a82d1be46d
This commit is contained in:
Qt Forward Merge Bot 2019-03-15 01:00:42 +01:00
commit e608b5d555
18 changed files with 193 additions and 81 deletions

View File

@ -125,11 +125,8 @@ goto doneargs
:platform
shift
if "%~1" == "win32-msvc2012" goto msvc
if "%~1" == "win32-msvc2013" goto msvc
if "%~1" == "win32-msvc2015" goto msvc
if "%~1" == "win32-msvc2017" goto msvc
set PLATFORM=%~1
if "%PLATFORM:~0,10%" == "win32-msvc" goto msvc
goto nextarg
:msvc
echo. >&2
@ -150,7 +147,7 @@ goto doneargs
:doneargs
rem Find various executables
for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C
for %%C in (clang-cl.exe clang.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C
rem Determine host spec
@ -161,6 +158,8 @@ if "%PLATFORM%" == "" (
set PLATFORM=win32-msvc
) else if not "%clang-cl.exe%" == "" (
set PLATFORM=win32-clang-msvc
) else if not "%clang.exe%" == "" (
set PLATFORM=win32-clang-g++
) else if not "%g++.exe%" == "" (
set PLATFORM=win32-g++
) else (
@ -172,7 +171,7 @@ if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" (
echo Host platform '%PLATFORM%' is invalid. Aborting. >&2
exit /b 1
)
if "%PLATFORM:win32-g++=%" == "%PLATFORM%" (
if "%PLATFORM:g++=%" == "%PLATFORM%" (
if "%MAKE%" == "" (
if not "%jom.exe%" == "" (
set MAKE=jom

View File

@ -69,7 +69,7 @@ class LcdNumber : public QFrame
//! [6]
public:
//! [6] //! [7]
LcdNumber(QWidget *parent = 0);
LcdNumber(QWidget *parent = nullptr);
//! [7]
//! [8]

View File

@ -330,7 +330,7 @@
arguments can have default values. Consider QObject::destroyed():
\code
void destroyed(QObject* = 0);
void destroyed(QObject* = nullptr);
\endcode
When a QObject is deleted, it emits this QObject::destroyed()
@ -339,7 +339,7 @@
A suitable slot signature might be:
\code
void objectDestroyed(QObject* obj = 0);
void objectDestroyed(QObject* obj = nullptr);
\endcode
To connect the signal to the slot, we use QObject::connect().

View File

@ -120,15 +120,30 @@ private:
return category; \
}
#define qCDebug(category, ...) \
#if !defined(QT_NO_DEBUG_OUTPUT)
# define qCDebug(category, ...) \
for (bool qt_category_enabled = category().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).debug(__VA_ARGS__)
#define qCInfo(category, ...) \
#else
# define qCDebug(category, ...) QT_NO_QDEBUG_MACRO()
#endif
#if !defined(QT_NO_INFO_OUTPUT)
# define qCInfo(category, ...) \
for (bool qt_category_enabled = category().isInfoEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).info(__VA_ARGS__)
#define qCWarning(category, ...) \
#else
# define qCInfo(category, ...) QT_NO_QDEBUG_MACRO()
#endif
#if !defined(QT_NO_WARNING_OUTPUT)
# define qCWarning(category, ...) \
for (bool qt_category_enabled = category().isWarningEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).warning(__VA_ARGS__)
#else
# define qCWarning(category, ...) QT_NO_QDEBUG_MACRO()
#endif
#define qCCritical(category, ...) \
for (bool qt_category_enabled = category().isCriticalEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).critical(__VA_ARGS__)
@ -144,26 +159,28 @@ private:
}
// check for enabled category inside QMessageLogger.
#define qCDebug qDebug
#define qCInfo qInfo
#define qCWarning qWarning
#if !defined(QT_NO_DEBUG_OUTPUT)
# define qCDebug qDebug
#else
# define qCDebug(category) QT_NO_QDEBUG_MACRO()
#endif
#if !defined(QT_NO_INFO_OUTPUT)
# define qCInfo qInfo
#else
# define qCInfo(category) QT_NO_QDEBUG_MACRO()
#endif
#if !defined(QT_NO_WARNING_OUTPUT)
# define qCWarning qWarning
#else
# define qCWarning(category) QT_NO_QDEBUG_MACRO()
#endif
#define qCCritical qCritical
#endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN)
#if defined(QT_NO_DEBUG_OUTPUT)
# undef qCDebug
# define qCDebug(category) QT_NO_QDEBUG_MACRO()
#endif
#if defined(QT_NO_INFO_OUTPUT)
# undef qCInfo
# define qCInfo(category) QT_NO_QDEBUG_MACRO()
#endif
#if defined(QT_NO_WARNING_OUTPUT)
# undef qCWarning
# define qCWarning(category) QT_NO_QDEBUG_MACRO()
#endif
QT_END_NAMESPACE
#endif // QLOGGINGCATEGORY_H

View File

@ -420,7 +420,7 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag)
\value IllegalSimpleType The CBOR stream contains a Simple Type encoded incorrectly (data is
corrupt and the error is not recoverable).
\value InvalidUtf8String The CBOR stream contains a text string that does not decode properly
as UTF (data is corrupt and the error is not recoverable).
as UTF-8 (data is corrupt and the error is not recoverable).
\value DataTooLarge CBOR string, map or array is too big and cannot be parsed by Qt
(internal limitation, but the error is not recoverable).
\value NestingTooDeep Too many levels of arrays or maps encountered while processing the
@ -429,6 +429,24 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag)
support (internal limitation, but the error is not recoverable).
*/
// Convert from CborError to QCborError.
//
// Centralized in a function in case we need to make more adjustments in the
// future.
static QCborError fromCborError(CborError err)
{
return { QCborError::Code(int(err)) };
}
// Convert to CborError from QCborError.
//
// Centralized in a function in case we need to make more adjustments in the
// future.
static CborError toCborError(QCborError c)
{
return CborError(int(c.c));
}
/*!
\variable QCborError::c
\internal
@ -499,8 +517,8 @@ QString QCborError::toString() const
return QStringLiteral("Internal limitation: unsupported type");
}
// get the error from TinyCBOR
CborError err = CborError(int(c));
// get the error string from TinyCBOR
CborError err = toCborError(*this);
return QString::fromLatin1(cbor_error_string(err));
}
@ -1839,8 +1857,7 @@ public:
if (err != CborErrorUnexpectedEOF)
corrupt = true;
// our error codes are the same (for now)
lastError = { QCborError::Code(err) };
lastError = fromCborError(err);
}
void updateBufferAfterString(qsizetype offset, qsizetype size)

View File

@ -37,6 +37,12 @@ QT_BEGIN_NAMESPACE
a scope.
*/
/*! \fn template <typename F> void QScopeGuard<F>::dismiss()
Disarms the scope guard, so that the function \e F will not be called at
the end of the scope.
*/
/*!
\fn template <typename F> const QScopeGuard<F> qScopeGuard(F f)
\inmodule QtCore

View File

@ -313,7 +313,7 @@ QOpenGLContext *qt_gl_global_share_context()
\section1 Context Resource Sharing
Resources, such as framebuffer objects, textures, and vertex buffer objects
Resources such as textures and vertex buffer objects
can be shared between contexts. Use setShareContext() before calling
create() to specify that the contexts should share these resources.
QOpenGLContext internally keeps track of a QOpenGLContextGroup object which

View File

@ -291,4 +291,13 @@ QVariant QWindowsNativeInterface::gpu() const
return GpuDescription::detect().toVariant();
}
QVariant QWindowsNativeInterface::gpuList() const
{
QVariantList result;
const auto gpus = GpuDescription::detectAll();
for (const auto &gpu : gpus)
result.append(gpu.toVariant());
return result;
}
QT_END_NAMESPACE

View File

@ -66,6 +66,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
Q_PROPERTY(QVariant gpu READ gpu STORED false)
Q_PROPERTY(QVariant gpuList READ gpuList STORED false)
public:
void *nativeResourceForIntegration(const QByteArray &resource) override;
@ -91,6 +92,7 @@ public:
void setAsyncExpose(bool value);
QVariant gpu() const;
QVariant gpuList() const;
QVariantMap windowProperties(QPlatformWindow *window) const override;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const override;

View File

@ -62,19 +62,70 @@ QT_BEGIN_NAMESPACE
static const DWORD VENDOR_ID_AMD = 0x1002;
static GpuDescription adapterIdentifierToGpuDescription(const D3DADAPTER_IDENTIFIER9 &adapterIdentifier)
{
GpuDescription result;
result.vendorId = adapterIdentifier.VendorId;
result.deviceId = adapterIdentifier.DeviceId;
result.revision = adapterIdentifier.Revision;
result.subSysId = adapterIdentifier.SubSysId;
QVector<int> version(4, 0);
version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version
version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build
result.driverVersion = QVersionNumber(version);
result.driverName = adapterIdentifier.Driver;
result.description = adapterIdentifier.Description;
return result;
}
class QDirect3D9Handle
{
public:
Q_DISABLE_COPY(QDirect3D9Handle)
QDirect3D9Handle();
~QDirect3D9Handle();
bool isValid() const { return m_direct3D9 != nullptr; }
UINT adapterCount() const { return m_direct3D9 ? m_direct3D9->GetAdapterCount() : 0u; }
bool retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const;
private:
QSystemLibrary m_d3d9lib;
IDirect3D9 *m_direct3D9 = nullptr;
};
QDirect3D9Handle::QDirect3D9Handle() :
m_d3d9lib(QStringLiteral("d3d9"))
{
using PtrDirect3DCreate9 = IDirect3D9 *(WINAPI *)(UINT);
if (m_d3d9lib.load()) {
if (auto direct3DCreate9 = (PtrDirect3DCreate9)m_d3d9lib.resolve("Direct3DCreate9"))
m_direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
}
}
QDirect3D9Handle::~QDirect3D9Handle()
{
if (m_direct3D9)
m_direct3D9->Release();
}
bool QDirect3D9Handle::retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const
{
return m_direct3D9
&& SUCCEEDED(m_direct3D9->GetAdapterIdentifier(n, 0, adapterIdentifier));
}
GpuDescription GpuDescription::detect()
{
typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT);
GpuDescription result;
QSystemLibrary d3d9lib(QStringLiteral("d3d9"));
if (!d3d9lib.load())
return result;
PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9");
if (!direct3DCreate9)
return result;
IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
if (!direct3D9)
QDirect3D9Handle direct3D9;
if (!direct3D9.isValid())
return result;
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
@ -85,20 +136,8 @@ GpuDescription GpuDescription::detect()
// and D3D uses by default. Therefore querying any additional adapters is
// futile and not useful for our purposes in general, except for
// identifying a few special cases later on.
HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier);
if (SUCCEEDED(hr)) {
result.vendorId = adapterIdentifier.VendorId;
result.deviceId = adapterIdentifier.DeviceId;
result.revision = adapterIdentifier.Revision;
result.subSysId = adapterIdentifier.SubSysId;
QVector<int> version(4, 0);
version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version
version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build
result.driverVersion = QVersionNumber(version);
result.driverName = adapterIdentifier.Driver;
result.description = adapterIdentifier.Description;
if (direct3D9.retrieveAdapterIdentifier(0, &adapterIdentifier)) {
result = adapterIdentifierToGpuDescription(adapterIdentifier);
isAMD = result.vendorId == VENDOR_ID_AMD;
}
@ -106,30 +145,41 @@ GpuDescription GpuDescription::detect()
// when starting apps on a screen connected to the Intel card) by looking
// for a default AMD adapter and an additional non-AMD one.
if (isAMD) {
const UINT adapterCount = direct3D9->GetAdapterCount();
const UINT adapterCount = direct3D9.adapterCount();
for (UINT adp = 1; adp < adapterCount; ++adp) {
hr = direct3D9->GetAdapterIdentifier(adp, 0, &adapterIdentifier);
if (SUCCEEDED(hr)) {
if (adapterIdentifier.VendorId != VENDOR_ID_AMD) {
// Bingo. Now figure out the display for the AMD card.
DISPLAY_DEVICE dd;
memset(&dd, 0, sizeof(dd));
dd.cb = sizeof(dd);
for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) {
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
// DeviceName is something like \\.\DISPLAY1 which can be used to
// match with the MONITORINFOEX::szDevice queried by QWindowsScreen.
result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName);
break;
}
if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier)
&& adapterIdentifier.VendorId != VENDOR_ID_AMD) {
// Bingo. Now figure out the display for the AMD card.
DISPLAY_DEVICE dd;
memset(&dd, 0, sizeof(dd));
dd.cb = sizeof(dd);
for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) {
if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
// DeviceName is something like \\.\DISPLAY1 which can be used to
// match with the MONITORINFOEX::szDevice queried by QWindowsScreen.
result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName);
break;
}
break;
}
break;
}
}
}
direct3D9->Release();
return result;
}
QVector<GpuDescription> GpuDescription::detectAll()
{
QVector<GpuDescription> result;
QDirect3D9Handle direct3D9;
if (const UINT adapterCount = direct3D9.adapterCount()) {
for (UINT adp = 0; adp < adapterCount; ++adp) {
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier))
result.append(adapterIdentifierToGpuDescription(adapterIdentifier));
}
}
return result;
}

View File

@ -42,6 +42,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qflags.h>
#include <QtCore/qvector.h>
#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@ -52,6 +53,7 @@ class QVariant;
struct GpuDescription
{
static GpuDescription detect();
static QVector<GpuDescription> detectAll();
QString toString() const;
QVariant toVariant() const;

View File

@ -746,7 +746,8 @@ QWindowsWindowData
const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);
QMargins invMargins = topLevel && !(result.flags & Qt::FramelessWindowHint) && QWindowsGeometryHint::positionIncludesFrame(w)
const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME));
QMargins invMargins = topLevel && hasFrame && QWindowsGeometryHint::positionIncludesFrame(w)
? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins();
qCDebug(lcQpaWindows).nospace()
@ -777,6 +778,7 @@ QWindowsWindowData
result.geometry = context->obtainedGeometry;
result.fullFrameMargins = context->margins;
result.embedded = embedded;
result.hasFrame = hasFrame;
result.customMargins = context->customMargins;
return result;
@ -2233,7 +2235,7 @@ void QWindowsWindow::setFullFrameMargins(const QMargins &newMargins)
QMargins QWindowsWindow::frameMargins() const
{
QMargins result = fullFrameMargins();
if (isTopLevel() && !(m_data.flags & Qt::FramelessWindowHint))
if (isTopLevel() && m_data.hasFrame)
result -= invisibleMargins(geometry().topLeft());
return result;
}

View File

@ -112,6 +112,7 @@ struct QWindowsWindowData
QMargins customMargins; // User-defined, additional frame for NCCALCSIZE
HWND hwnd = 0;
bool embedded = false;
bool hasFrame = false;
static QWindowsWindowData create(const QWindow *w,
const QWindowsWindowData &parameters,

View File

@ -185,10 +185,10 @@ public:
QXcbWindow *platformWindowFromId(xcb_window_t id);
inline xcb_timestamp_t time() const { return m_time; }
inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
inline void setTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_time)) m_time = t; }
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
inline void setNetWmUserTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_netWmUserTime)) m_netWmUserTime = t; }
xcb_timestamp_t getTimestamp();
xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
@ -264,6 +264,8 @@ private:
void destroyScreen(QXcbScreen *screen);
void initializeScreens();
bool compressEvent(xcb_generic_event_t *event) const;
inline bool timeGreaterThan(xcb_timestamp_t a, xcb_timestamp_t b) const
{ return static_cast<int32_t>(a - b) > 0 || b == XCB_CURRENT_TIME; }
#if QT_CONFIG(xcb_xinput)
void xi2SetupDevice(void *info, bool removeExisting = true);

View File

@ -1722,7 +1722,7 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
QStringList importPaths;
importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml"));
importPaths += rootPath;
importPaths += shellQuote(rootPath);
for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths))
importPaths += shellQuote(qmlImportPath);

View File

@ -752,9 +752,9 @@ void WriteInitialization::acceptWidget(DomWidget *node)
static const QLatin1String realPropertyNames[] = {
QLatin1String("visible"),
QLatin1String("cascadingSectionResizes"),
QLatin1String("minimumSectionSize"), // before defaultSectionSize
QLatin1String("defaultSectionSize"),
QLatin1String("highlightSections"),
QLatin1String("minimumSectionSize"),
QLatin1String("showSortIndicator"),
QLatin1String("stretchLastSection"),
};

View File

@ -244,6 +244,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
case QVariant::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
cb->setFrame(false);
cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy());
return cb; }
#endif
#if QT_CONFIG(spinbox)
@ -252,12 +253,14 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(0);
sb->setMaximum(INT_MAX);
sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
case QVariant::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(datetimeedit)
@ -284,6 +287,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
sb->setMaximum(DBL_MAX);
sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(lineedit)

View File

@ -53,6 +53,7 @@ void tst_QNoDebug::noDebugOutput() const
// should do nothing
qDebug() << "foo";
qCDebug(cat) << "foo";
qCDebug(cat, "foo");
// qWarning still works, though
QTest::ignoreMessage(QtWarningMsg, "bar");