From a6348870ee1fc7b0270ceebf0f13dee7e5e54719 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 27 Nov 2013 11:19:09 +0100 Subject: Revert 99480d5420c0beea6771be582c039b550a4461f5 The Mac OS X platform plugin has been fixed so that this hack is no longer needed. Not to mention that it breaks on XCB. We keep the warning about bad exposes from the plugin in debug mode. These are still useful for tracking down future bugs. Task-number: QTBUG-35143 Change-Id: I5125f7ae2b7fd77c55e9a29b10aa5434598a9ea9 Reviewed-by: Ulf Hermann Reviewed-by: Gabriel de Dietrich --- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 16 ---------------- src/quick/scenegraph/qsgthreadedrenderloop_p.h | 2 -- 2 files changed, 18 deletions(-) (limited to 'src/quick') diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 850a463c3e..acd07cf6cd 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -817,7 +817,6 @@ void QSGThreadedRenderLoop::show(QQuickWindow *window) win.thread = new QSGRenderThread(this, QQuickWindowPrivate::get(window)->context); win.timerId = 0; win.updateDuringSync = false; - win.gotBrokenExposeFromPlatformPlugin = false; m_windows << win; } @@ -883,19 +882,6 @@ void QSGThreadedRenderLoop::exposureChanged(QQuickWindow *window) } } -void QSGThreadedRenderLoop::resize(QQuickWindow *window) -{ - Window *w = windowFor(m_windows, window); - if (w - && w->gotBrokenExposeFromPlatformPlugin - && window->width() > 0 && window->height() > 0 - && w->window->geometry().intersects(w->window->screen()->availableGeometry())) { - w->gotBrokenExposeFromPlatformPlugin = false; - handleExposure(w); - } -} - - /*! Will post an event to the render thread that this window should start to render. @@ -909,8 +895,6 @@ void QSGThreadedRenderLoop::handleExposure(Window *w) #ifndef QT_NO_DEBUG qWarning("QSGThreadedRenderLoop: expose event received for window with invalid geometry."); #endif - w->gotBrokenExposeFromPlatformPlugin = true; - return; } // Because we are going to bind a GL context to it, make sure it diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h index 844d180788..5943d0bd08 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h +++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h @@ -60,7 +60,6 @@ public: void show(QQuickWindow *window); void hide(QQuickWindow *window); - void resize(QQuickWindow *window); void windowDestroyed(QQuickWindow *window); void exposureChanged(QQuickWindow *window); @@ -90,7 +89,6 @@ private: QSGRenderThread *thread; int timerId; uint updateDuringSync : 1; - uint gotBrokenExposeFromPlatformPlugin : 1; }; friend class QSGRenderThread; -- cgit v1.2.3 From d0644b040eb09e1ed147ff15e7c926c9e318cbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 27 Nov 2013 17:57:25 +0100 Subject: Ensure that QML Windows respect the default platform window state The 'visible' property of a Window would be set on the baseclass QWindow like any other property during QML component creation, which would cause create() to be called and the platform window would be created. This left the 'visibility' of the QML window as Windowed, not respecting the platform defaults for how windows should be shown. The user would have to explicitly set "visibility: Window.AutomaticVisibility" for this default to apply, which doesn't make sense -- it should be the default. We solve this by deferring setVisible and setVisibility on the window until the component is complete and we have a full picture of its state. We then ask the platform for the default state based on the window flags (ensuring that eg "flags: Qt.Popup" will not result in maximized windows on iOS and Android), and apply the deferred visibility. The deferred visibility may still be 'false', but setting the window state makes sense anyways, so that a later "visible = true" will apply the default window state. Deferring platform window creation until the geometry has been potentially set from user code also has the benefit that the platform window can check the geometry and apply a default geometry if it's null. This was not possible when the 'visible' property was a regular property, as you could not know if the user's geometry changes would come after platform window creation. Task-number: QTBUG-35174 Change-Id: Icf3236187992048a85b2196c059f9b54699041a4 Reviewed-by: Simon Hausmann Reviewed-by: Robin Burchell Reviewed-by: Gunnar Sletta --- src/quick/items/qquickwindowmodule.cpp | 80 +++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) (limited to 'src/quick') diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index b91edc2fd5..cd1b68991d 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -45,12 +45,50 @@ #include #include +#include +#include +#include + QT_BEGIN_NAMESPACE class QQuickWindowQmlImpl : public QQuickWindow, public QQmlParserStatus { Q_INTERFACES(QQmlParserStatus) Q_OBJECT + + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged) + +public: + QQuickWindowQmlImpl(QWindow *parent = 0) + : QQuickWindow(parent) + , m_complete(false) + , m_visible(isVisible()) + , m_visibility(AutomaticVisibility) + { + connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged); + connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged); + } + + void setVisible(bool visible) { + if (!m_complete) + m_visible = visible; + else + QQuickWindow::setVisible(visible); + } + + void setVisibility(Visibility visibility) + { + if (!m_complete) + m_visibility = visibility; + else + QQuickWindow::setVisibility(m_visibility); + } + +Q_SIGNALS: + void visibleChanged(bool arg); + void visibilityChanged(QWindow::Visibility visibility); + protected: void classBegin() { //Give QQuickView behavior when created from QML with QQmlApplicationEngine @@ -61,7 +99,47 @@ protected: } } - void componentComplete() {} + void componentComplete() { + m_complete = true; + + // We have deferred window creation until we have the full picture of what + // the user wanted in terms of window state, geometry, visibility, etc. + + if ((m_visibility == Hidden && m_visible) || (m_visibility > AutomaticVisibility && !m_visible)) { + QQmlData *data = QQmlData::get(this); + Q_ASSERT(data && data->context); + + QQmlError error; + error.setObject(this); + + const QQmlContextData* urlContext = data->context; + while (urlContext && urlContext->url.isEmpty()) + urlContext = urlContext->parent; + error.setUrl(urlContext ? urlContext->url : QUrl()); + + QString objectId = data->context->findObjectId(this); + if (!objectId.isEmpty()) + error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", + "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId)); + else + error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", + "Conflicting properties 'visible' and 'visibility'")); + + QQmlEnginePrivate::get(data->context->engine)->warning(error); + } + + if (m_visibility == AutomaticVisibility) { + setWindowState(QGuiApplicationPrivate::platformIntegration()->defaultWindowState(flags())); + setVisible(m_visible); + } else { + setVisibility(m_visibility); + } + } + +private: + bool m_complete; + bool m_visible; + Visibility m_visibility; }; void QQuickWindowModule::defineModule() -- cgit v1.2.3 From 8029a015b4a11c48a262f0e9fc8b4a2674fbd505 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 28 Nov 2013 11:44:39 +0100 Subject: Handle boundingboxes with NaN in them. NaN does not compare well with other floats. The result is that the bounding box is left at its initial values, FLT_MAX for top-left and FLT_MIN for bottom-right. If so, treat geometry as invalid, aka infinite. Task-number: QTBUG-35192 Change-Id: I1df6987d56a0ce1f500b0eba344a5dcbc55f80a4 Reviewed-by: Mitch Curtis Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 11 +++++++---- src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 4 ---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/quick') diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 79b5de72c0..676efe84bc 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -590,15 +590,18 @@ void Element::computeBounds() } bounds.map(*node->matrix()); - if (!qIsFinite(bounds.tl.x)) + if (!qIsFinite(bounds.tl.x) || bounds.tl.x == FLT_MAX) bounds.tl.x = -FLT_MAX; - if (!qIsFinite(bounds.tl.y)) + if (!qIsFinite(bounds.tl.y) || bounds.tl.y == FLT_MAX) bounds.tl.y = -FLT_MAX; - if (!qIsFinite(bounds.br.x)) + if (!qIsFinite(bounds.br.x) || bounds.br.x == -FLT_MAX) bounds.br.x = FLT_MAX; - if (!qIsFinite(bounds.br.y)) + if (!qIsFinite(bounds.br.y) || bounds.br.y == -FLT_MAX) bounds.br.y = FLT_MAX; + Q_ASSERT(bounds.tl.x <= bounds.br.x); + Q_ASSERT(bounds.tl.y <= bounds.br.y); + boundsOutsideFloatRange = bounds.isOutsideFloatRange(); } diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 95e111552d..5404b669a0 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -104,8 +104,6 @@ struct Rect { tl.y = pt.y; if (pt.y > br.y) br.y = pt.y; - Q_ASSERT(tl.x <= br.x); - Q_ASSERT(tl.y <= br.y); } void operator |= (const Rect &r) { @@ -117,8 +115,6 @@ struct Rect { br.x = r.br.x; if (r.br.y > br.y) br.y = r.br.y; - Q_ASSERT(tl.x <= br.x); - Q_ASSERT(tl.y <= br.y); } void map(const QMatrix4x4 &m); -- cgit v1.2.3 From 86b3c8b26dcebb2ced30c52eddf2ffb5e9c52762 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 26 Nov 2013 11:15:05 +0100 Subject: Doc: Change the order of QQuickText function definitions For Text QML type, some property and method documentation is missing from the output because in the source file, they appear before the '\qmltype Text' command. This change reorders the functions so that qdoc will see all documentation for Text QML type. Task-number: QTBUG-35018 Change-Id: Icd995f66679d5105912ee12a7aeffd510921a54d Reviewed-by: Martin Smith Reviewed-by: J-P Nurmi --- src/quick/items/qquicktext.cpp | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'src/quick') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index d62bf8efa1..ad904a2579 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -297,44 +297,6 @@ qreal QQuickTextPrivate::getImplicitHeight() const return implicitHeight; } -/*! - \qmlproperty enumeration QtQuick::Text::renderType - - Override the default rendering type for this component. - - Supported render types are: - \list - \li Text.QtRendering - the default - \li Text.NativeRendering - \endlist - - Select Text.NativeRendering if you prefer text to look native on the target platform and do - not require advanced features such as transformation of the text. Using such features in - combination with the NativeRendering render type will lend poor and sometimes pixelated - results. - - On HighDpi "retina" displays and mobile and embedded platforms, this property is ignored - and QtRendering is always used. -*/ -QQuickText::RenderType QQuickText::renderType() const -{ - Q_D(const QQuickText); - return d->renderType; -} - -void QQuickText::setRenderType(QQuickText::RenderType renderType) -{ - Q_D(QQuickText); - if (d->renderType == renderType) - return; - - d->renderType = renderType; - emit renderTypeChanged(); - - if (isComponentComplete()) - d->updateLayout(); -} - void QQuickText::q_imagesLoaded() { Q_D(QQuickText); @@ -641,17 +603,6 @@ void QQuickTextLine::setY(qreal y) m_line->setPosition(QPointF(m_line->x(), y)); } -/*! - \qmlmethod QtQuick::Text::doLayout() - - Triggers a re-layout of the displayed text. -*/ -void QQuickText::doLayout() -{ - Q_D(QQuickText); - d->updateSize(); -} - bool QQuickTextPrivate::isLineLaidOutConnected() { Q_Q(QQuickText); @@ -2665,4 +2616,53 @@ void QQuickText::hoverLeaveEvent(QHoverEvent *event) d->processHoverEvent(event); } +/*! + \qmlproperty enumeration QtQuick::Text::renderType + + Override the default rendering type for this component. + + Supported render types are: + \list + \li Text.QtRendering - the default + \li Text.NativeRendering + \endlist + + Select Text.NativeRendering if you prefer text to look native on the target platform and do + not require advanced features such as transformation of the text. Using such features in + combination with the NativeRendering render type will lend poor and sometimes pixelated + results. + + On HighDpi "retina" displays and mobile and embedded platforms, this property is ignored + and QtRendering is always used. +*/ +QQuickText::RenderType QQuickText::renderType() const +{ + Q_D(const QQuickText); + return d->renderType; +} + +void QQuickText::setRenderType(QQuickText::RenderType renderType) +{ + Q_D(QQuickText); + if (d->renderType == renderType) + return; + + d->renderType = renderType; + emit renderTypeChanged(); + + if (isComponentComplete()) + d->updateLayout(); +} + +/*! + \qmlmethod QtQuick::Text::doLayout() + + Triggers a re-layout of the displayed text. +*/ +void QQuickText::doLayout() +{ + Q_D(QQuickText); + d->updateSize(); +} + QT_END_NAMESPACE -- cgit v1.2.3 From d05671788d2a87ef93c7e368754b5106c5dbe733 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 12 Nov 2013 16:53:47 +0100 Subject: Safely abort when we don't succeed in creating a GL context. Task-number: QTBUG-33363 (cherry-picked from commit 12eab9162781) Change-Id: Ia2b0c329157786cb4ec703989f12d2fdb1ce6bc8 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/qsgrenderloop.cpp | 1 + src/quick/scenegraph/qsgwindowsrenderloop.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/quick') diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 9c39ef65f9..aa0d7b5a6c 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -277,6 +277,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (QSGContext::sharedOpenGLContext()) gl->setShareContext(QSGContext::sharedOpenGLContext()); if (!gl->create()) { + qWarning("QtQuick: failed to create OpenGL context"); delete gl; gl = 0; } else { diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 03ee4992bc..0c128d5cae 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -180,13 +180,20 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window) m_gl->setFormat(window->requestedFormat()); if (QSGContext::sharedOpenGLContext()) m_gl->setShareContext(QSGContext::sharedOpenGLContext()); - m_gl->create(); + bool created = m_gl->create(); + if (!created) { + qWarning("QtQuick: failed to create OpenGL context"); + delete m_gl; + m_gl = 0; + return; + } QSG_RENDER_TIMING_SAMPLE(time_created); RLDEBUG(" - making current"); - m_gl->makeCurrent(window); + bool current = m_gl->makeCurrent(window); RLDEBUG(" - initializing SG"); QSG_RENDER_TIMING_SAMPLE(time_current); - QQuickWindowPrivate::get(window)->context->initialize(m_gl); + if (current) + m_rc->initialize(m_gl); #ifndef QSG_NO_RENDER_TIMING if (qsg_render_timing) { -- cgit v1.2.3 From 3b7a8d9d5e214a88f5855800e7bf54da4425d7b9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 2 Dec 2013 22:44:21 +0100 Subject: Fix style animations to stop when the item is hidden QStyleAnimation automatically stopped for hidden QWidgets, but didn't know anything about QQuickItems and kept animating regardless of their visibility. QStyleAnimation was changed so that it will keep animating only as long as the animation target accepts animation updates. This change ensures that the style animation updates are accepted only when the item is visible. Task-number: QTBUG-35319 Change-Id: I3c93a653316b8abbbc32940cd7499b660828eff8 Reviewed-by: Gunnar Sletta Reviewed-by: Jens Bache-Wiig --- src/quick/items/qquickitem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/quick') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index c11bf904be..a0329f7afc 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7012,7 +7012,10 @@ bool QQuickItem::event(QEvent *ev) } else #endif // QT_NO_IM if (ev->type() == QEvent::StyleAnimationUpdate) { - update(); + if (isVisible()) { + ev->accept(); + update(); + } return true; } return QObject::event(ev); -- cgit v1.2.3