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

Change-Id: If4974bbf0a166de244dd57cb71b05fa28bcc34ce
This commit is contained in:
Qt Forward Merge Bot 2019-04-05 01:00:49 +02:00
commit eb606d85b3
23 changed files with 109 additions and 84 deletions

View File

@ -321,10 +321,10 @@ function(QT5_ADD_BIG_RESOURCES outfiles )
add_custom_command(OUTPUT ${tmpoutfile} add_custom_command(OUTPUT ${tmpoutfile}
COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile} COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM) DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM)
set_source_files_properties(${tmpoutfile} PROPERTIES SKIP_AUTOMOC ON)
set_source_files_properties(${tmpoutfile} PROPERTIES SKIP_AUTOUIC ON)
add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile}) add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile})
add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile}) add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile})
set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOMOC OFF)
set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOUIC OFF)
add_dependencies(rcc_object_${outfilename} big_resources_${outfilename}) add_dependencies(rcc_object_${outfilename} big_resources_${outfilename})
add_custom_command(OUTPUT ${outfile} add_custom_command(OUTPUT ${outfile}
COMMAND ${Qt5Core_RCC_EXECUTABLE} COMMAND ${Qt5Core_RCC_EXECUTABLE}

View File

@ -1085,7 +1085,7 @@ QAbstractAnimation::State QAbstractAnimation::state() const
/*! /*!
If this animation is part of a QAnimationGroup, this function returns a If this animation is part of a QAnimationGroup, this function returns a
pointer to the group; otherwise, it returns 0. pointer to the group; otherwise, it returns \nullptr.
\sa QAnimationGroup::addAnimation() \sa QAnimationGroup::addAnimation()
*/ */

View File

@ -1242,7 +1242,7 @@ QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba)
\obsolete \obsolete
Returns the codec used by QObject::tr() on its argument. If this Returns the codec used by QObject::tr() on its argument. If this
function returns 0 (the default), tr() assumes Latin-1. function returns \nullptr (the default), tr() assumes Latin-1.
*/ */
/*! /*!

View File

@ -555,7 +555,7 @@ typedef struct _FILE_ID_INFO {
#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602 #endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
// File ID for Windows up to version 7. // File ID for Windows up to version 7 and FAT32 drives
static inline QByteArray fileId(HANDLE handle) static inline QByteArray fileId(HANDLE handle)
{ {
#ifndef Q_OS_WINRT #ifndef Q_OS_WINRT
@ -588,6 +588,8 @@ QByteArray fileIdWin8(HANDLE handle)
result += ':'; result += ':';
// Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one. // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex(); result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
} else {
result = fileId(handle); // GetFileInformationByHandleEx() is observed to fail for FAT32, QTBUG-74759
} }
return result; return result;
#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE #else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE

View File

@ -134,7 +134,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return QString(); return QString();
} }
} }
#ifndef Q_OS_WASM
qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir)); qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir));
#endif
} else { } else {
fileInfo.setFile(xdgRuntimeDir); fileInfo.setFile(xdgRuntimeDir);
if (!fileInfo.exists()) { if (!fileInfo.exists()) {

View File

@ -162,7 +162,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher()
Returns a pointer to the event dispatcher object for the specified Returns a pointer to the event dispatcher object for the specified
\a thread. If \a thread is zero, the current thread is used. If no \a thread. If \a thread is zero, the current thread is used. If no
event dispatcher exists for the specified thread, this function event dispatcher exists for the specified thread, this function
returns 0. returns \nullptr.
\b{Note:} If Qt is built without thread support, the \a thread \b{Note:} If Qt is built without thread support, the \a thread
argument is ignored. argument is ignored.

View File

@ -2917,7 +2917,7 @@ bool QCoreApplication::hasPendingEvents()
/*! /*!
Returns a pointer to the event dispatcher object for the main thread. If no Returns a pointer to the event dispatcher object for the main thread. If no
event dispatcher exists for the thread, this function returns 0. event dispatcher exists for the thread, this function returns \nullptr.
*/ */
QAbstractEventDispatcher *QCoreApplication::eventDispatcher() QAbstractEventDispatcher *QCoreApplication::eventDispatcher()
{ {

View File

@ -349,7 +349,7 @@ bool QMetaObject::inherits(const QMetaObject *metaObject) const noexcept
\internal \internal
Returns \a obj if object \a obj inherits from this Returns \a obj if object \a obj inherits from this
meta-object; otherwise returns 0. meta-object; otherwise returns \nullptr.
*/ */
QObject *QMetaObject::cast(QObject *obj) const QObject *QMetaObject::cast(QObject *obj) const
{ {
@ -361,7 +361,7 @@ QObject *QMetaObject::cast(QObject *obj) const
\internal \internal
Returns \a obj if object \a obj inherits from this Returns \a obj if object \a obj inherits from this
meta-object; otherwise returns 0. meta-object; otherwise returns \nullptr.
*/ */
const QObject *QMetaObject::cast(const QObject *obj) const const QObject *QMetaObject::cast(const QObject *obj) const
{ {

View File

@ -2383,7 +2383,7 @@ static void err_info_about_objects(const char * func,
/*! /*!
Returns a pointer to the object that sent the signal, if called in Returns a pointer to the object that sent the signal, if called in
a slot activated by a signal; otherwise it returns 0. The pointer a slot activated by a signal; otherwise it returns \nullptr. The pointer
is valid only during the execution of the slot that calls this is valid only during the execution of the slot that calls this
function from this object's thread context. function from this object's thread context.

View File

@ -999,7 +999,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
/*! /*!
Returns the address of the exported symbol \a symbol. The library is Returns the address of the exported symbol \a symbol. The library is
loaded if necessary. The function returns 0 if the symbol could loaded if necessary. The function returns \nullptr if the symbol could
not be resolved or if the library could not be loaded. not be resolved or if the library could not be loaded.
Example: Example:
@ -1032,7 +1032,7 @@ QFunctionPointer QLibrary::resolve(const char *symbol)
include the platform-specific file suffix; (see \l{fileName}). The include the platform-specific file suffix; (see \l{fileName}). The
library remains loaded until the application exits. library remains loaded until the application exits.
The function returns 0 if the symbol could not be resolved or if The function returns \nullptr if the symbol could not be resolved or if
the library could not be loaded. the library could not be loaded.
\sa resolve() \sa resolve()
@ -1052,7 +1052,7 @@ QFunctionPointer QLibrary::resolve(const QString &fileName, const char *symbol)
(see \l{fileName}). The library remains loaded until the application exits. (see \l{fileName}). The library remains loaded until the application exits.
\a verNum is ignored on Windows. \a verNum is ignored on Windows.
The function returns 0 if the symbol could not be resolved or if The function returns \nullptr if the symbol could not be resolved or if
the library could not be loaded. the library could not be loaded.
\sa resolve() \sa resolve()
@ -1073,7 +1073,7 @@ QFunctionPointer QLibrary::resolve(const QString &fileName, int verNum, const ch
(see \l{fileName}). The library remains loaded until the application exits. (see \l{fileName}). The library remains loaded until the application exits.
\a version is ignored on Windows. \a version is ignored on Windows.
The function returns 0 if the symbol could not be resolved or if The function returns \nullptr if the symbol could not be resolved or if
the library could not be loaded. the library could not be loaded.
\sa resolve() \sa resolve()

View File

@ -174,7 +174,7 @@ QPluginLoader::~QPluginLoader()
/*! /*!
Returns the root component object of the plugin. The plugin is Returns the root component object of the plugin. The plugin is
loaded if necessary. The function returns 0 if the plugin could loaded if necessary. The function returns \nullptr if the plugin could
not be loaded or if the root component object could not be not be loaded or if the root component object could not be
instantiated. instantiated.

View File

@ -920,7 +920,7 @@ QThreadPrivate::~QThreadPrivate()
\since 5.0 \since 5.0
Returns a pointer to the event dispatcher object for the thread. If no event Returns a pointer to the event dispatcher object for the thread. If no event
dispatcher exists for the thread, this function returns 0. dispatcher exists for the thread, this function returns \nullptr.
*/ */
QAbstractEventDispatcher *QThread::eventDispatcher() const QAbstractEventDispatcher *QThread::eventDispatcher() const
{ {

View File

@ -875,7 +875,7 @@
\b without ensuring that it cannot get deleted. To have that guarantee, \b without ensuring that it cannot get deleted. To have that guarantee,
use toStrongRef(), which returns a QSharedPointer object. If this use toStrongRef(), which returns a QSharedPointer object. If this
function can determine that the pointer has already been deleted, it function can determine that the pointer has already been deleted, it
returns 0. returns \nullptr.
It is ok to obtain the value of the pointer and using that value itself, It is ok to obtain the value of the pointer and using that value itself,
like for example in debugging statements: like for example in debugging statements:

View File

@ -1145,6 +1145,15 @@ bool QTextCursor::isNull() const
\a pos using a \c MoveMode specified by \a m. The cursor is positioned \a pos using a \c MoveMode specified by \a m. The cursor is positioned
between characters. between characters.
\note The "characters" in this case refer to the string of QChar
objects, i.e. 16-bit Unicode characters, and \a pos is considered
an index into this string. This does not necessarily correspond to
individual graphemes in the writing system, as a single grapheme may
be represented by multiple Unicode characters, such as in the case
of surrogate pairs, linguistic ligatures or diacritics. For a more
generic approach to navigating the document, use movePosition(),
which will respect the actual grapheme boundaries in the text.
\sa position(), movePosition(), anchor() \sa position(), movePosition(), anchor()
*/ */
void QTextCursor::setPosition(int pos, MoveMode m) void QTextCursor::setPosition(int pos, MoveMode m)
@ -1176,6 +1185,13 @@ void QTextCursor::setPosition(int pos, MoveMode m)
Returns the absolute position of the cursor within the document. Returns the absolute position of the cursor within the document.
The cursor is positioned between characters. The cursor is positioned between characters.
\note The "characters" in this case refer to the string of QChar
objects, i.e. 16-bit Unicode characters, and the position is considered
an index into this string. This does not necessarily correspond to
individual graphemes in the writing system, as a single grapheme may
be represented by multiple Unicode characters, such as in the case
of surrogate pairs, linguistic ligatures or diacritics.
\sa setPosition(), movePosition(), anchor(), positionInBlock() \sa setPosition(), movePosition(), anchor(), positionInBlock()
*/ */
int QTextCursor::position() const int QTextCursor::position() const
@ -1192,6 +1208,13 @@ int QTextCursor::position() const
This is equivalent to \c{ position() - block().position()}. This is equivalent to \c{ position() - block().position()}.
\note The "characters" in this case refer to the string of QChar
objects, i.e. 16-bit Unicode characters, and the position is considered
an index into this string. This does not necessarily correspond to
individual graphemes in the writing system, as a single grapheme may
be represented by multiple Unicode characters, such as in the case
of surrogate pairs, linguistic ligatures or diacritics.
\sa position() \sa position()
*/ */
int QTextCursor::positionInBlock() const int QTextCursor::positionInBlock() const

View File

@ -163,12 +163,14 @@
return NSViewLayerContentsRedrawDuringViewResize; return NSViewLayerContentsRedrawDuringViewResize;
} }
#if 0 // Disabled until we enable lazy backingstore resizing
- (NSViewLayerContentsPlacement)layerContentsPlacement - (NSViewLayerContentsPlacement)layerContentsPlacement
{ {
// Always place the layer at top left without any automatic scaling, // Always place the layer at top left without any automatic scaling,
// so that we can re-use larger layers when resizing a window down. // so that we can re-use larger layers when resizing a window down.
return NSViewLayerContentsPlacementTopLeft; return NSViewLayerContentsPlacementTopLeft;
} }
#endif
- (void)updateMetalLayerDrawableSize:(CAMetalLayer *)layer - (void)updateMetalLayerDrawableSize:(CAMetalLayer *)layer
{ {

View File

@ -164,6 +164,7 @@ function QtLoader(config)
// Set contentEditable in order to enable clipboard events; hide the resulting focus frame. // Set contentEditable in order to enable clipboard events; hide the resulting focus frame.
canvas.contentEditable = true; canvas.contentEditable = true;
canvas.style.outline = "0px solid transparent"; canvas.style.outline = "0px solid transparent";
canvas.style.caretColor = "transparent";
canvas.style.cursor = "default"; canvas.style.cursor = "default";
return canvas; return canvas;

View File

@ -193,7 +193,7 @@ void QWasmCompositor::requestRedraw()
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
} }
QWindow *QWasmCompositor::windowAt(QPoint p, int padding) const QWindow *QWasmCompositor::windowAt(QPoint globalPoint, int padding) const
{ {
int index = m_windowStack.count() - 1; int index = m_windowStack.count() - 1;
// qDebug() << "window at" << "point" << p << "window count" << index; // qDebug() << "window at" << "point" << p << "window count" << index;
@ -205,7 +205,7 @@ QWindow *QWasmCompositor::windowAt(QPoint p, int padding) const
QRect geometry = compositedWindow.window->windowFrameGeometry() QRect geometry = compositedWindow.window->windowFrameGeometry()
.adjusted(-padding, -padding, padding, padding); .adjusted(-padding, -padding, padding, padding);
if (compositedWindow.visible && geometry.contains(p)) if (compositedWindow.visible && geometry.contains(globalPoint))
return m_windowStack.at(index)->window(); return m_windowStack.at(index)->window();
--index; --index;
} }

View File

@ -116,7 +116,7 @@ public:
void redrawWindowContent(); void redrawWindowContent();
void requestRedraw(); void requestRedraw();
QWindow *windowAt(QPoint p, int padding = 0) const; QWindow *windowAt(QPoint globalPoint, int padding = 0) const;
QWindow *keyWindow() const; QWindow *keyWindow() const;
bool event(QEvent *event); bool event(QEvent *event);

View File

@ -549,22 +549,22 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode,
void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent)
{ {
auto timestamp = mouseEvent->timestamp; auto timestamp = mouseEvent->timestamp;
QPoint point(mouseEvent->targetX, mouseEvent->targetY); QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY);
QPoint globalPoint = screen()->geometry().topLeft() + targetPoint;
QEvent::Type buttonEventType = QEvent::None; QEvent::Type buttonEventType = QEvent::None;
Qt::MouseButton button = translateMouseButton(mouseEvent->button); Qt::MouseButton button = translateMouseButton(mouseEvent->button);
Qt::KeyboardModifiers modifiers = translateMouseEventModifier(mouseEvent); Qt::KeyboardModifiers modifiers = translateMouseEventModifier(mouseEvent);
QWindow *window2 = screen()->compositor()->windowAt(point, 5); QWindow *window2 = screen()->compositor()->windowAt(globalPoint, 5);
if (window2 != nullptr) if (window2 == nullptr)
lastWindow = window2; return;
lastWindow = window2;
QPoint localPoint = window2->mapFromGlobal(globalPoint);
bool interior = window2->geometry().contains(globalPoint);
QWasmWindow *htmlWindow = static_cast<QWasmWindow*>(window2->handle()); QWasmWindow *htmlWindow = static_cast<QWasmWindow*>(window2->handle());
bool interior = window2 && window2->geometry().contains(point);
QPoint localPoint(point.x() - window2->geometry().x(), point.y() - window2->geometry().y());
switch (eventType) { switch (eventType) {
case EMSCRIPTEN_EVENT_MOUSEDOWN: case EMSCRIPTEN_EVENT_MOUSEDOWN:
{ {
@ -580,18 +580,18 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
pressedWindow = window2; pressedWindow = window2;
buttonEventType = QEvent::MouseButtonPress; buttonEventType = QEvent::MouseButtonPress;
if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) { if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) {
if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(point)) if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(globalPoint))
draggedWindow = window2; draggedWindow = window2;
else if (htmlWindow && htmlWindow->isPointOnResizeRegion(point)) { else if (htmlWindow && htmlWindow->isPointOnResizeRegion(globalPoint)) {
draggedWindow = window2; draggedWindow = window2;
resizeMode = htmlWindow->resizeModeAtPoint(point); resizeMode = htmlWindow->resizeModeAtPoint(globalPoint);
resizePoint = point; resizePoint = globalPoint;
resizeStartRect = window2->geometry(); resizeStartRect = window2->geometry();
} }
} }
} }
htmlWindow->injectMousePressed(localPoint, point, button, modifiers); htmlWindow->injectMousePressed(localPoint, globalPoint, button, modifiers);
break; break;
} }
case EMSCRIPTEN_EVENT_MOUSEUP: case EMSCRIPTEN_EVENT_MOUSEUP:
@ -611,7 +611,7 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
} }
if (oldWindow) if (oldWindow)
oldWindow->injectMouseReleased(localPoint, point, button, modifiers); oldWindow->injectMouseReleased(localPoint, globalPoint, button, modifiers);
break; break;
} }
case EMSCRIPTEN_EVENT_MOUSEMOVE: // drag event case EMSCRIPTEN_EVENT_MOUSEMOVE: // drag event
@ -640,7 +640,7 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven
} }
if (window2 && interior) { if (window2 && interior) {
QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>( QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(
window2, timestamp, localPoint, point, pressedButtons, button, buttonEventType, modifiers); window2, timestamp, localPoint, globalPoint, pressedButtons, button, buttonEventType, modifiers);
} }
} }
@ -675,11 +675,13 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; QWasmEventTranslator *translator = (QWasmEventTranslator*)userData;
Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent); Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent);
auto timestamp = mouseEvent.timestamp; auto timestamp = mouseEvent.timestamp;
QPoint globalPoint(mouseEvent.canvasX, mouseEvent.canvasY); QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY);
QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint;
QWindow *window2 = eventTranslator->screen()->compositor()->windowAt(globalPoint, 5); QWindow *window2 = eventTranslator->screen()->compositor()->windowAt(globalPoint, 5);
if (!window2)
QPoint localPoint(globalPoint.x() - window2->geometry().x(), globalPoint.y() - window2->geometry().y()); return 0;
QPoint localPoint = window2->mapFromGlobal(globalPoint);
QPoint pixelDelta; QPoint pixelDelta;
@ -709,24 +711,28 @@ int QWasmEventTranslator::handleTouch(int eventType, const EmscriptenTouchEvent
const EmscriptenTouchPoint *touches = &touchEvent->touches[i]; const EmscriptenTouchPoint *touches = &touchEvent->touches[i];
QPoint point(touches->targetX, touches->targetY); QPoint targetPoint(touches->targetX, touches->targetY);
window2 = this->screen()->compositor()->windowAt(point, 5); QPoint globalPoint = screen()->geometry().topLeft() + targetPoint;
window2 = this->screen()->compositor()->windowAt(globalPoint, 5);
if (window2 == nullptr)
continue;
QWindowSystemInterface::TouchPoint touchPoint; QWindowSystemInterface::TouchPoint touchPoint;
touchPoint.area = QRect(0, 0, 8, 8); touchPoint.area = QRect(0, 0, 8, 8);
touchPoint.id = touches->identifier; touchPoint.id = touches->identifier;
touchPoint.pressure = 1.0; touchPoint.pressure = 1.0;
const QPointF screenPos(point); touchPoint.area.moveCenter(globalPoint);
touchPoint.area.moveCenter(screenPos);
const auto tp = pressedTouchIds.constFind(touchPoint.id); const auto tp = pressedTouchIds.constFind(touchPoint.id);
if (tp != pressedTouchIds.constEnd()) if (tp != pressedTouchIds.constEnd())
touchPoint.normalPosition = tp.value(); touchPoint.normalPosition = tp.value();
QPointF normalPosition(screenPos.x() / window2->width(), QPointF localPoint = QPointF(window2->mapFromGlobal(globalPoint));
screenPos.y() / window2->height()); QPointF normalPosition(localPoint.x() / window2->width(),
localPoint.y() / window2->height());
const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition); const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition);
touchPoint.normalPosition = normalPosition; touchPoint.normalPosition = normalPosition;

View File

@ -11,7 +11,7 @@
/* The contenteditable property is set to true for the canvas in order to support /* The contenteditable property is set to true for the canvas in order to support
clipboard events. Hide the resulting focus frame and set the cursor back to clipboard events. Hide the resulting focus frame and set the cursor back to
the default cursor. */ the default cursor. */
canvas { outline: 0px solid transparent; cursor:default } canvas { outline: 0px solid transparent; caret-color: transparent; cursor:default }
</style> </style>
</head> </head>
<body onload="init()"> <body onload="init()">

View File

@ -286,7 +286,7 @@
QStyleOption to a subclass (e.g., QStyleOptionFocusRect). For QStyleOption to a subclass (e.g., QStyleOptionFocusRect). For
safety, you can use qstyleoption_cast() to ensure that the safety, you can use qstyleoption_cast() to ensure that the
pointer type is correct. If the object isn't of the right type, pointer type is correct. If the object isn't of the right type,
qstyleoption_cast() returns 0. For example: qstyleoption_cast() returns \nullptr. For example:
\snippet code/doc_src_qt4-styles.cpp 0 \snippet code/doc_src_qt4-styles.cpp 0

View File

@ -1860,7 +1860,7 @@ void QTableWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
\fn QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const \fn QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const
Returns the item at the position equivalent to QPoint(\a{ax}, \a{ay}) in Returns the item at the position equivalent to QPoint(\a{ax}, \a{ay}) in
the table widget's coordinate system, or returns 0 if the specified point the table widget's coordinate system, or returns \nullptr if the specified point
is not covered by an item in the table widget. is not covered by an item in the table widget.
\sa item() \sa item()

View File

@ -59,25 +59,22 @@ class tst_QSizeGrip : public QObject
{ {
Q_OBJECT Q_OBJECT
public slots: public slots:
void initTestCase(); void cleanup();
void cleanupTestCase();
private slots: private slots:
void hideAndShowOnWindowStateChange_data(); void hideAndShowOnWindowStateChange_data();
void hideAndShowOnWindowStateChange(); void hideAndShowOnWindowStateChange();
void orientation(); void orientation();
void dontCrashOnTLWChange(); void dontCrashOnTLWChange();
private:
QLineEdit *dummyWidget;
}; };
class TestWidget : public QWidget class TestWidget : public QWidget
{ {
public: public:
TestWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QWidget(parent, flags) {} using QWidget::QWidget;
QSize sizeHint() const { return QSize(300, 200); }
void changeEvent(QEvent *event) QSize sizeHint() const override { return QSize(300, 200); }
void changeEvent(QEvent *event) override
{ {
QWidget::changeEvent(event); QWidget::changeEvent(event);
if (isWindow() && event->type() == QEvent::WindowStateChange) if (isWindow() && event->type() == QEvent::WindowStateChange)
@ -85,16 +82,9 @@ public:
} }
}; };
void tst_QSizeGrip::initTestCase() void tst_QSizeGrip::cleanup()
{ {
dummyWidget = new QLineEdit; QVERIFY(QApplication::topLevelWidgets().isEmpty());
dummyWidget->show();
}
void tst_QSizeGrip::cleanupTestCase()
{
delete dummyWidget;
dummyWidget = 0;
} }
void tst_QSizeGrip::hideAndShowOnWindowStateChange_data() void tst_QSizeGrip::hideAndShowOnWindowStateChange_data()
@ -111,46 +101,45 @@ void tst_QSizeGrip::hideAndShowOnWindowStateChange()
QSKIP("Broken on WinRT - QTBUG-68297"); QSKIP("Broken on WinRT - QTBUG-68297");
#endif #endif
QWidget *parentWidget = windowType == Qt::Window ? 0 : new QWidget; QScopedPointer<QWidget> parentWidget;
TestWidget *widget = new TestWidget(parentWidget, Qt::WindowFlags(windowType)); if (windowType != Qt::Window)
QSizeGrip *sizeGrip = new QSizeGrip(widget); parentWidget.reset(new QWidget);
QScopedPointer<TestWidget> widget(new TestWidget(parentWidget.data(), Qt::WindowFlags(windowType)));
QSizeGrip *sizeGrip = new QSizeGrip(widget.data());
// Normal. // Normal.
if (parentWidget) if (parentWidget)
parentWidget->show(); parentWidget->show();
else else
widget->show(); widget->show();
QVERIFY(sizeGrip->isVisible()); QTRY_VERIFY(sizeGrip->isVisible());
widget->showFullScreen(); widget->showFullScreen();
QVERIFY(!sizeGrip->isVisible()); QTRY_VERIFY(!sizeGrip->isVisible());
widget->showNormal(); widget->showNormal();
QVERIFY(sizeGrip->isVisible()); QTRY_VERIFY(sizeGrip->isVisible());
widget->showMaximized(); widget->showMaximized();
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QVERIFY(!sizeGrip->isVisible()); QTRY_VERIFY(!sizeGrip->isVisible());
#else #else
QEXPECT_FAIL("", "QTBUG-23681", Abort); QEXPECT_FAIL("", "QTBUG-23681", Abort);
QVERIFY(sizeGrip->isVisible()); QVERIFY(sizeGrip->isVisible());
#endif #endif
widget->showNormal(); widget->showNormal();
QVERIFY(sizeGrip->isVisible()); QTRY_VERIFY(sizeGrip->isVisible());
sizeGrip->hide(); sizeGrip->hide();
QVERIFY(!sizeGrip->isVisible()); QTRY_VERIFY(!sizeGrip->isVisible());
widget->showFullScreen(); widget->showFullScreen();
widget->showNormal(); widget->showNormal();
QVERIFY(!sizeGrip->isVisible()); QTRY_VERIFY(!sizeGrip->isVisible());
widget->showMaximized(); widget->showMaximized();
widget->showNormal(); widget->showNormal();
QVERIFY(!sizeGrip->isVisible()); QTRY_VERIFY(!sizeGrip->isVisible());
delete widget;
delete parentWidget;
} }
void tst_QSizeGrip::orientation() void tst_QSizeGrip::orientation()
@ -196,10 +185,10 @@ void tst_QSizeGrip::dontCrashOnTLWChange()
QMdiArea mdiArea; QMdiArea mdiArea;
mdiArea.show(); mdiArea.show();
QMainWindow *mw = new QMainWindow(); QScopedPointer<QMainWindow> mw(new QMainWindow);
QMdiSubWindow *mdi = mdiArea.addSubWindow(mw); QMdiSubWindow *mdi = mdiArea.addSubWindow(mw.data());
mw->statusBar()->setSizeGripEnabled(true); mw->statusBar()->setSizeGripEnabled(true);
mdiArea.removeSubWindow(mw); mdiArea.removeSubWindow(mw.data());
delete mdi; delete mdi;
mw->show(); mw->show();
@ -209,7 +198,7 @@ void tst_QSizeGrip::dontCrashOnTLWChange()
QEXPECT_FAIL("", "Broken on WinRT - QTBUG-68297", Abort); QEXPECT_FAIL("", "Broken on WinRT - QTBUG-68297", Abort);
#endif #endif
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
QVERIFY(QTest::qWaitForWindowExposed(mw)); QVERIFY(QTest::qWaitForWindowExposed(mw.data()));
} }
QTEST_MAIN(tst_QSizeGrip) QTEST_MAIN(tst_QSizeGrip)