From 6cbb84d24f157cf630a87195e88cf700e1777ebf Mon Sep 17 00:00:00 2001 From: Liang Jian Date: Tue, 4 Nov 2014 17:18:15 +0800 Subject: Fix memory leak in QQmlLocaleData Call the correct destructor in QQmlLocaleData::destroy() to prevent memory leak. Change-Id: Id5b7657443521fbb46486bfbc5575d914c7c7b71 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmllocale_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index a29b86fbea..3787517038 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -174,7 +174,7 @@ struct QQmlLocaleData : public QV4::Object private: static void destroy(Managed *that) { - static_cast(that)->~QQmlLocaleData(); + static_cast(that)->d()->~Data(); } }; -- cgit v1.2.3 From 25b6fae1eb26645a30b3e7e254ce0b585757351c Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Tue, 4 Nov 2014 14:55:26 +0100 Subject: qv4: assign split edges to the correct loop group edge splitting had a strange logic to assign the inserted statement to a loop, which would go wrong for example for the statement just after the loop header. I guess that was done to increase the likelihood that the goto removed from the final instructions. Given that we are talking about critical edges it is always possible to emit them in a bad order, and I do not think that the old logic was really better than simply always use the loop group of the target which is always correct. It might be worthwhile to ensure that the block it is emitted just before the target block, or improve the handling of empty gotos in the backend, but in this patch we go for the simplest solution. If one would notice worse code, either one of the provious improvements could be done, or the old logic could be kept, changing just the if (container == 0) to container = toBB->containingGroup(); Change-Id: I26a488e9e2cb2b692fa8187ee658fb4dd98bfa8b Task-number: QTBUG-41766 Reviewed-by: Bernd Lamecker Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4ssa.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index d67b88b718..31e3ed867e 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -2991,15 +2991,7 @@ void splitCriticalEdges(IR::Function *f, DominatorTree &df, StatementWorklist &w toBB->in[inIdx] = newBB; newBB->out.append(toBB); - BasicBlock *container = 0; - for (container = fromBB->containingGroup(); container; container = container->containingGroup()) { - if (container == toBB || container == toBB->containingGroup()) - break; - } - if (container == 0) - container = fromBB->containingGroup(); - - newBB->setContainingGroup(container); + newBB->setContainingGroup(toBB->containingGroup()); // patch the terminator Stmt *terminator = fromBB->terminator(); -- cgit v1.2.3 From ebc342ea38b4a5d2e3b83a47f375fa1737acaf49 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 5 Nov 2014 13:35:12 +0100 Subject: Add a debug function to save contents of distance field cache Just copy the one from QSGSharedDistanceFieldCache with some compile fixes to the superclass so we store the default cache as well. Change-Id: I1fcc390601eea58f8b7729c9cead418e4c94714c Reviewed-by: Yoann Lopes --- src/quick/scenegraph/qsgadaptationlayer.cpp | 170 ++++++++++++++++++++ src/quick/scenegraph/qsgadaptationlayer_p.h | 4 + .../qsgshareddistancefieldglyphcache.cpp | 173 --------------------- src/quick/scenegraph/scenegraph.pri | 1 + 4 files changed, 175 insertions(+), 173 deletions(-) diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 80234d54f5..9e4b572ea6 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -174,6 +174,11 @@ void QSGDistanceFieldGlyphCache::update() storeGlyphs(distanceFields); +#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) + foreach (Texture texture, m_textures) + saveTexture(texture.textureId, texture.size.width(), texture.size.height()); +#endif + if (QSG_LOG_TIME_GLYPH().isDebugEnabled()) { quint64 now = qsg_render_timer.elapsed(); qCDebug(QSG_LOG_TIME_GLYPH, @@ -284,6 +289,171 @@ void QSGDistanceFieldGlyphCache::updateTexture(GLuint oldTex, GLuint newTex, con } } +#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) +#include + +void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) const +{ + GLuint fboId; + glGenFramebuffers(1, &fboId); + + GLuint tmpTexture = 0; + glGenTextures(1, &tmpTexture); + glBindTexture(GL_TEXTURE_2D, tmpTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); + glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, + tmpTexture, 0); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, textureId); + + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); + + GLfloat textureCoordinateArray[8]; + textureCoordinateArray[0] = 0.0f; + textureCoordinateArray[1] = 0.0f; + textureCoordinateArray[2] = 1.0f; + textureCoordinateArray[3] = 0.0f; + textureCoordinateArray[4] = 1.0f; + textureCoordinateArray[5] = 1.0f; + textureCoordinateArray[6] = 0.0f; + textureCoordinateArray[7] = 1.0f; + + GLfloat vertexCoordinateArray[8]; + vertexCoordinateArray[0] = -1.0f; + vertexCoordinateArray[1] = -1.0f; + vertexCoordinateArray[2] = 1.0f; + vertexCoordinateArray[3] = -1.0f; + vertexCoordinateArray[4] = 1.0f; + vertexCoordinateArray[5] = 1.0f; + vertexCoordinateArray[6] = -1.0f; + vertexCoordinateArray[7] = 1.0f; + + glViewport(0, 0, width, height); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); + + { + static const char *vertexShaderSource = + "attribute vec4 vertexCoordsArray; \n" + "attribute vec2 textureCoordArray; \n" + "varying vec2 textureCoords; \n" + "void main(void) \n" + "{ \n" + " gl_Position = vertexCoordsArray; \n" + " textureCoords = textureCoordArray; \n" + "} \n"; + + static const char *fragmentShaderSource = + "varying vec2 textureCoords; \n" + "uniform sampler2D texture; \n" + "void main() \n" + "{ \n" + " gl_FragColor = texture2D(texture, textureCoords); \n" + "} \n"; + + GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); + GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + + if (vertexShader == 0 || fragmentShader == 0) { + GLenum error = glGetError(); + qWarning("SharedGraphicsCacheServer::setupShaderPrograms: Failed to create shaders. (GL error: %x)", + error); + return; + } + + glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); + glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); + glCompileShader(vertexShader); + + GLint len = 1; + glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len); + + char infoLog[2048]; + glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) { + qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling vertex shader:\n %s", + infoLog); + } + + glCompileShader(fragmentShader); + glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) { + qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling fragent shader:\n %s", + infoLog); + } + + GLuint shaderProgram = glCreateProgram(); + glAttachShader(shaderProgram, vertexShader); + glAttachShader(shaderProgram, fragmentShader); + + glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray"); + glBindAttribLocation(shaderProgram, 1, "textureCoordArray"); + + glLinkProgram(shaderProgram); + glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) { + qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems linking shaders:\n %s", + infoLog); + } + + glUseProgram(shaderProgram); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + + int textureUniformLocation = glGetUniformLocation(shaderProgram, "texture"); + glUniform1i(textureUniformLocation, 0); + } + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + { + GLenum error = glGetError(); + if (error != GL_NO_ERROR) { + qWarning("SharedGraphicsCacheServer::readBackBuffer: glDrawArrays reported error 0x%x", + error); + } + } + + uchar *data = new uchar[width * height * 4]; + + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + + QImage image(data, width, height, QImage::Format_ARGB32); + + QByteArray fileName = m_referenceFont.familyName().toLatin1() + '_' + QByteArray::number(textureId); + fileName = fileName.replace('/', '_').replace(' ', '_') + ".png"; + + image.save(QString::fromLocal8Bit(fileName)); + + { + GLenum error = glGetError(); + if (error != GL_NO_ERROR) { + qWarning("SharedGraphicsCacheServer::readBackBuffer: glReadPixels reported error 0x%x", + error); + } + } + + glDisableVertexAttribArray(0); + glDisableVertexAttribArray(1); + + glDeleteFramebuffers(1, &fboId); + glDeleteTextures(1, &tmpTexture); + + delete[] data; +} +#endif + void QSGNodeVisitorEx::visitChildren(QSGNode *node) { for (QSGNode *child = node->firstChild(); child; child = child->nextSibling()) { diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index a63299fcde..962fc5a98a 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -357,6 +357,10 @@ protected: GlyphData &glyphData(glyph_t glyph); +#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) + void saveTexture(GLuint textureId, int width, int height) const; +#endif + inline bool isCoreProfile() const { return m_coreProfile; } private: diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp index 6f54b258ff..f635ccd17b 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp @@ -399,176 +399,6 @@ void QSGSharedDistanceFieldGlyphCache::unregisterOwnerElement(QQuickItem *ownerE } } -#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG_) -# include - -void QSGSharedDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) -{ - GLuint fboId; - glGenFramebuffers(1, &fboId); - - GLuint tmpTexture = 0; - glGenTextures(1, &tmpTexture); - glBindTexture(GL_TEXTURE_2D, tmpTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - - glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); - glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, - tmpTexture, 0); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, textureId); - - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - - GLfloat textureCoordinateArray[8]; - textureCoordinateArray[0] = 0.0f; - textureCoordinateArray[1] = 0.0f; - textureCoordinateArray[2] = 1.0f; - textureCoordinateArray[3] = 0.0f; - textureCoordinateArray[4] = 1.0f; - textureCoordinateArray[5] = 1.0f; - textureCoordinateArray[6] = 0.0f; - textureCoordinateArray[7] = 1.0f; - - GLfloat vertexCoordinateArray[8]; - vertexCoordinateArray[0] = -1.0f; - vertexCoordinateArray[1] = -1.0f; - vertexCoordinateArray[2] = 1.0f; - vertexCoordinateArray[3] = -1.0f; - vertexCoordinateArray[4] = 1.0f; - vertexCoordinateArray[5] = 1.0f; - vertexCoordinateArray[6] = -1.0f; - vertexCoordinateArray[7] = 1.0f; - - glViewport(0, 0, width, height); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); - - { - static const char vertexShaderSource[] = - "attribute highp vec4 vertexCoordsArray; \n" - "attribute highp vec2 textureCoordArray; \n" - "varying highp vec2 textureCoords; \n" - "void main(void) \n" - "{ \n" - " gl_Position = vertexCoordsArray; \n" - " textureCoords = textureCoordArray; \n" - "} \n"; - - static const char fragmentShaderSource[] = - "varying highp vec2 textureCoords; \n" - "uniform sampler2D texture; \n" - "void main() \n" - "{ \n" - " gl_FragColor = texture2D(texture, textureCoords); \n" - "} \n"; - - GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); - GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - - if (vertexShader == 0 || fragmentShader == 0) { - GLenum error = glGetError(); - qWarning("SharedGraphicsCacheServer::setupShaderPrograms: Failed to create shaders. (GL error: %x)", - error); - return; - } - - glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); - glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); - glCompileShader(vertexShader); - - GLint len = 1; - glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len); - - char infoLog[2048]; - glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling vertex shader:\n %s", - infoLog); - //return; - } - - glCompileShader(fragmentShader); - glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling fragent shader:\n %s", - infoLog); - //return; - } - - GLuint shaderProgram = glCreateProgram(); - glAttachShader(shaderProgram, vertexShader); - glAttachShader(shaderProgram, fragmentShader); - - glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray"); - glBindAttribLocation(shaderProgram, 1, "textureCoordArray"); - - glLinkProgram(shaderProgram); - glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems linking shaders:\n %s", - infoLog); - //return; - } - - glUseProgram(shaderProgram); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); - - int textureUniformLocation = glGetUniformLocation(shaderProgram, "_qt_texture"); - glUniform1i(textureUniformLocation, 0); - } - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - { - GLenum error = glGetError(); - if (error != GL_NO_ERROR) { - qWarning("SharedGraphicsCacheServer::readBackBuffer: glDrawArrays reported error 0x%x", - error); - } - } - - uchar *data = new uchar[width * height * 4]; - - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); - - QImage image(width, height, QImage::Format_ARGB32); - quint32 *dest = reinterpret_cast(image.bits()); - for (int i=0; itextureIdForBuffer(it.key()); texture.size = m_sharedGraphicsCache->sizeOfBuffer(it.key()); -#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG_) - saveTexture(texture.textureId, texture.size.width(), texture.size.height()); -#endif setGlyphsTexture(it.value().glyphs, texture); ++it; diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri index bcb523f90d..480ac5e569 100644 --- a/src/quick/scenegraph/scenegraph.pri +++ b/src/quick/scenegraph/scenegraph.pri @@ -1,6 +1,7 @@ !contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL # DEFINES += QSG_SEPARATE_INDEX_BUFFER +# DEFINES += QSG_DISTANCEFIELD_CACHE_DEBUG # Core API HEADERS += \ -- cgit v1.2.3 From 5280e866f76e38f2bf1c226ff896b4649194eec4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 5 Nov 2014 14:02:55 +0100 Subject: Mark cleanup function as unused if compiled with QT_QML_NO_DEBUGGER The static cleanup function in qqmldebugserver.cpp is only used if the debug server is actually created. If not we can mark it as unused to avoid compile warnings. Enclosing it in #ifdef would be uglier. Task-number: QTBUG-42394 Change-Id: Ieb7fa38ecb346e80ce815ced85eb3a168bad9d99 Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmldebugserver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp index 59ac548fa8..2a2ce663bc 100644 --- a/src/qml/debugger/qqmldebugserver.cpp +++ b/src/qml/debugger/qqmldebugserver.cpp @@ -419,6 +419,7 @@ QQmlDebugServer::QQmlDebugServer() } } #else + Q_UNUSED(&cleanup) if (!appD->qmljsDebugArgumentsString().isEmpty()) { qWarning() << QString(QLatin1String( "QML Debugger: Ignoring \"-qmljsdebugger=%1\". " -- cgit v1.2.3 From 77711c65c1fdb6c5d94d26fef828959d29643516 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Nov 2014 17:23:11 +0100 Subject: Add attached Window::contentItem property This is essential to the Qt Quick Controls for implementing floating text selection handle popups. Change-Id: Ibae65110a5db6d65dacd197fef3ad567d11342dc Reviewed-by: Alan Alpert Reviewed-by: Shawn Rutledge --- src/quick/items/qquickwindow.cpp | 8 ++++++++ src/quick/items/qquickwindowattached.cpp | 6 ++++++ src/quick/items/qquickwindowattached_p.h | 3 +++ tests/auto/quick/qquickwindow/data/windowattached.qml | 2 ++ tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 2 ++ 5 files changed, 21 insertions(+) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index f6c1412aff..619e539204 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1250,6 +1250,14 @@ bool QQuickWindow::isPersistentSceneGraph() const +/*! + \qmlattachedproperty Item Window::contentItem + \since 5.4 + + This attached property holds the invisible root item of the scene or + \c null if the item is not in a window. The Window attached property + can be attached to any Item. +*/ /*! \property QQuickWindow::contentItem diff --git a/src/quick/items/qquickwindowattached.cpp b/src/quick/items/qquickwindowattached.cpp index 121da9e5d9..f74e903be3 100644 --- a/src/quick/items/qquickwindowattached.cpp +++ b/src/quick/items/qquickwindowattached.cpp @@ -65,6 +65,11 @@ QQuickItem *QQuickWindowAttached::activeFocusItem() const return (m_window ? m_window->activeFocusItem() : Q_NULLPTR); } +QQuickItem *QQuickWindowAttached::contentItem() const +{ + return (m_window ? m_window->contentItem() : Q_NULLPTR); +} + void QQuickWindowAttached::windowChanged(QQuickWindow *window) { if (window != m_window) { @@ -83,6 +88,7 @@ void QQuickWindowAttached::windowChanged(QQuickWindow *window) emit activeChanged(); if (!oldWindow || window->activeFocusItem() != oldWindow->activeFocusItem()) emit activeFocusItemChanged(); + emit contentItemChanged(); // QQuickWindowQmlImpl::visibilityChanged also exists, and window might even // be QQuickWindowQmlImpl, but that's not what we are connecting to. diff --git a/src/quick/items/qquickwindowattached_p.h b/src/quick/items/qquickwindowattached_p.h index 12dd273d60..7c2b0bc873 100644 --- a/src/quick/items/qquickwindowattached_p.h +++ b/src/quick/items/qquickwindowattached_p.h @@ -49,6 +49,7 @@ class Q_AUTOTEST_EXPORT QQuickWindowAttached : public QObject Q_PROPERTY(QWindow::Visibility visibility READ visibility NOTIFY visibilityChanged) Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged) + Q_PROPERTY(QQuickItem* contentItem READ contentItem NOTIFY contentItemChanged) public: QQuickWindowAttached(QObject* attachee); @@ -56,12 +57,14 @@ public: QWindow::Visibility visibility() const; bool isActive() const; QQuickItem* activeFocusItem() const; + QQuickItem* contentItem() const; Q_SIGNALS: void visibilityChanged(); void activeChanged(); void activeFocusItemChanged(); + void contentItemChanged(); protected Q_SLOTS: void windowChanged(QQuickWindow*); diff --git a/tests/auto/quick/qquickwindow/data/windowattached.qml b/tests/auto/quick/qquickwindow/data/windowattached.qml index e000d5c6fd..0e3f1d4b62 100644 --- a/tests/auto/quick/qquickwindow/data/windowattached.qml +++ b/tests/auto/quick/qquickwindow/data/windowattached.qml @@ -6,6 +6,7 @@ Rectangle { width: 100 height: 100 property bool windowActive: root.Window.active + property Item contentItem: root.Window.contentItem Text { objectName: "rectangleWindowText" anchors.centerIn: parent @@ -20,6 +21,7 @@ Rectangle { objectName: "extraWindowText" anchors.centerIn: parent text: (extraWindow.active ? "active" : "inactive") + "\nvisibility: " + Window.visibility + property Item contentItem: Window.contentItem } } } diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 5bd7492d70..043203c256 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1952,6 +1952,7 @@ void tst_qquickwindow::attachedProperty() view.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&view)); QVERIFY(view.rootObject()->property("windowActive").toBool()); + QCOMPARE(view.rootObject()->property("contentItem").value(), view.contentItem()); QQuickWindow *innerWindow = view.rootObject()->findChild("extraWindow"); QVERIFY(innerWindow); @@ -1961,6 +1962,7 @@ void tst_qquickwindow::attachedProperty() QQuickText *text = view.rootObject()->findChild("extraWindowText"); QVERIFY(text); QCOMPARE(text->text(), QLatin1String("active\nvisibility: 2")); + QCOMPARE(text->property("contentItem").value(), innerWindow->contentItem()); } class RenderJob : public QRunnable -- cgit v1.2.3 From b74268ef3e82f0fb9c1ed5392efd0e19c08ee5d5 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Wed, 5 Nov 2014 11:27:15 +0100 Subject: qv4: assign split of edges to loop header to the correct group (i.e assign split edges to the correct loop group, now for real) The fix of 25b6fae1eb26645a30b3e7e254ce0b585757351c did try fix QTBUG-41766 and simplify the logic to assign the inserted statement to a loop group. Unfortunately that was incorrect if the target basic block starts a group. In that case if the source was already inside the group we should add it to the target basic block, otherwise to the one containing the target block (as before). There was no visible regression caused by this. Change-Id: Id50c42305fc5ac6aedaffa89d8f8dc3b5e976aa4 Task-number: QTBUG-41766 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4ssa.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 31e3ed867e..d2222a0458 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -2991,7 +2991,19 @@ void splitCriticalEdges(IR::Function *f, DominatorTree &df, StatementWorklist &w toBB->in[inIdx] = newBB; newBB->out.append(toBB); - newBB->setContainingGroup(toBB->containingGroup()); + // add newBB to the correct loop group + if (toBB->isGroupStart()) { + BasicBlock *container; + for (container = fromBB->containingGroup(); container; container = container->containingGroup()) + if (container == toBB) + break; + if (container == toBB) // if we were already inside the toBB loop + newBB->setContainingGroup(toBB); + else + newBB->setContainingGroup(toBB->containingGroup()); + } else { + newBB->setContainingGroup(toBB->containingGroup()); + } // patch the terminator Stmt *terminator = fromBB->terminator(); -- cgit v1.2.3 From e703f4170e851da50fad14df9fdd5a923bacf7e8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Nov 2014 09:22:11 +0100 Subject: Initialize member variable QSGAnimationDriver::m_lag. Fixes purify warning: [W] UMR: Uninitialized memory read in QSGAnimationDriver::advance(void) {1 occurrence} QSGAnimationDriver::advance(void) [qtdeclarative\src\quick\scenegraph\qsgcontext.cpp:221] Task-number: QTBUG-42213 Change-Id: Ide35830c60c5935644747da5cfbad1cdbd357232 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgcontext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index b5bdbde3ad..90102f1110 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -161,6 +161,7 @@ public: , m_time(0) , m_vsync(0) , m_mode(VSyncMode) + , m_lag(0) , m_bad(0) , m_good(0) { -- cgit v1.2.3 From 61dd293a145a3881c6ff4a223121f655f1f8d0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 6 Nov 2014 10:53:49 +0100 Subject: Stabilize tst_QQuickAccessible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no reason to wait for the window to activate Task-number: QTBUG-42355 Change-Id: I5faaff5bddd367e6dd57a6a922011c87c847148e Reviewed-by: Tony Sarajärvi --- tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 921c81ae89..f6d5d16605 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -383,8 +383,6 @@ void tst_QQuickAccessible::checkableTest() QScopedPointer window(new QQuickView()); window->setSource(testFileUrl("checkbuttons.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickItem *contentItem = window->contentItem(); QVERIFY(contentItem); @@ -462,8 +460,6 @@ void tst_QQuickAccessible::ignoredTest() QScopedPointer window(new QQuickView()); window->setSource(testFileUrl("ignored.qml")); window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickItem *contentItem = window->contentItem(); QVERIFY(contentItem); -- cgit v1.2.3 From a4877338826381d454dfdae74242a007b3aac9e0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 6 Nov 2014 14:40:37 +0100 Subject: Avoid stack overflow when destroying InternalClass If there are deep object hierarchies connected to an InternalClass the recursive nature of the destroy() method could lead to a stack overflow. By changing the recursion into an iteration this is avoided. Change-Id: I6667f268a366749c2dbc5f7147882388f192a9c5 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4internalclass.cpp | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index a59c3892a1..bb22e30ac1 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -412,25 +412,24 @@ InternalClass *InternalClass::frozen() void InternalClass::destroy() { - if (!engine) - return; - engine = 0; - - propertyTable.~PropertyHash(); - nameMap.~SharedInternalClassData(); - propertyData.~SharedInternalClassData(); + QList destroyStack; + destroyStack.append(this); - if (m_sealed) - m_sealed->destroy(); - - if (m_frozen) - m_frozen->destroy(); - - for (QHash::ConstIterator it = transitions.begin(), end = transitions.end(); - it != end; ++it) - it.value()->destroy(); - - transitions.clear(); + while (!destroyStack.isEmpty()) { + InternalClass *next = destroyStack.takeLast(); + if (!next->engine) + continue; + next->engine = 0; + next->propertyTable.~PropertyHash(); + next->nameMap.~SharedInternalClassData(); + next->propertyData.~SharedInternalClassData(); + if (next->m_sealed) + destroyStack.append(next->m_sealed); + if (next->m_frozen) + destroyStack.append(next->m_frozen); + destroyStack.append(next->transitions.values()); + next->transitions.clear(); + } } struct InternalClassPoolVisitor -- cgit v1.2.3 From efa81f8354f70d99e6341ffa5428495b28e68641 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 6 Nov 2014 11:43:19 +0100 Subject: Inspector: Do not assert when trying to stream QModelIndex Some QVariant's like QModelIndex cannot be streamed in a meaningful way: QDataType::save() will return false for them. However, this leads to a qWarning and Q_ASSERT in QVariant::operator<<(). To prevent this we're calling QDataType::save() manually beforehand. We however throw away the result if it succeeds, and still call QVariant::operator<<() to get the benefits of the QDataStream version handling. The alternatives would be to make QVariant::operator<<() not assert, or blacklist all known types with problems manually. Both seem to be difficult though ... Change-Id: I4f5fe6d5a3a076c24fbc73371a4d12d720de53da Task-number: QTBUG-42438 Reviewed-by: Ulf Hermann Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmlenginedebugservice.cpp | 12 +++++-- .../tst_qqmlenginedebugservice.cpp | 40 +++++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp index cb533a0459..088f3203d6 100644 --- a/src/qml/debugger/qqmlenginedebugservice.cpp +++ b/src/qml/debugger/qqmlenginedebugservice.cpp @@ -96,8 +96,16 @@ QDataStream &operator>>(QDataStream &ds, QDataStream &operator<<(QDataStream &ds, const QQmlEngineDebugService::QQmlObjectProperty &data) { - ds << (int)data.type << data.name << data.value << data.valueTypeName - << data.binding << data.hasNotifySignal; + ds << (int)data.type << data.name; + // check first whether the data can be saved + // (otherwise we assert in QVariant::operator<<) + QByteArray buffer; + QDataStream fakeStream(&buffer, QIODevice::WriteOnly); + if (QMetaType::save(fakeStream, data.value.type(), data.value.constData())) + ds << data.value; + else + ds << QVariant(); + ds << data.valueTypeName << data.binding << data.hasNotifySignal; return ds; } diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 5bbbe8e1e9..7c931928d4 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -73,6 +74,16 @@ signals: }; QML_DECLARE_TYPE(NonScriptProperty) +class CustomTypes : public QObject +{ + Q_OBJECT + Q_PROPERTY(QModelIndex modelIndex READ modelIndex) +public: + CustomTypes(QObject *parent = 0) : QObject(parent) {} + + QModelIndex modelIndex() { return QModelIndex(); } +}; + class tst_QQmlEngineDebugService : public QObject { Q_OBJECT @@ -125,6 +136,7 @@ private slots: void setBindingInStates(); void regression_QTCREATORBUG_7451(); + void queryObjectWithNonStreamableTypes(); }; QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject( @@ -314,6 +326,12 @@ void tst_QQmlEngineDebugService::initTestCase() "}\n" ; + // test non-streamable properties + qmlRegisterType("Backend", 1, 0, "CustomTypes"); + qml << "import Backend 1.0\n" + "CustomTypes {}" + ; + for (int i=0; i= 0); QCOMPARE(context.contexts[0].name, QString("tst_QQmlDebug_childContext")); } @@ -819,6 +837,26 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451() } } +void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes() +{ + bool success; + + QmlDebugObjectReference rootObject = findRootObject(4, true); + + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); + unconnected->queryObject(rootObject, &success); + QVERIFY(!success); + delete unconnected; + + m_dbg->queryObject(rootObject, &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); + + QmlDebugObjectReference obj = m_dbg->object(); + + QCOMPARE(findProperty(obj.properties, "modelIndex").value, QVariant()); +} + void tst_QQmlEngineDebugService::queryExpressionResult() { -- cgit v1.2.3 From 911b940c97e88dd9769d4831807e132706c38125 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 6 Nov 2014 11:35:35 +0100 Subject: Debug: Make it possible to save distance field cache on Windows This makes compilation possible of the saveTexture() function which is used to store the distance field glyph cache on disk when debugging. It also changes the warnings output from here to have no prefix, since this is anyway always available as the context in Qt 5. Change-Id: If3b64f0921a59c485b5321a5465369708e764afc Reviewed-by: Yoann Lopes --- src/quick/scenegraph/qsgadaptationlayer.cpp | 142 +++++++++++++--------------- 1 file changed, 67 insertions(+), 75 deletions(-) diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 9e4b572ea6..83704cf0ec 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -294,30 +294,32 @@ void QSGDistanceFieldGlyphCache::updateTexture(GLuint oldTex, GLuint newTex, con void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) const { + QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); + GLuint fboId; - glGenFramebuffers(1, &fboId); + functions->glGenFramebuffers(1, &fboId); GLuint tmpTexture = 0; - glGenTextures(1, &tmpTexture); - glBindTexture(GL_TEXTURE_2D, tmpTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_2D, 0); - - glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); - glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, - tmpTexture, 0); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, textureId); - - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); + functions->glGenTextures(1, &tmpTexture); + functions->glBindTexture(GL_TEXTURE_2D, tmpTexture); + functions->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + functions->glBindTexture(GL_TEXTURE_2D, 0); + + functions->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); + functions->glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, + tmpTexture, 0); + + functions->glActiveTexture(GL_TEXTURE0); + functions->glBindTexture(GL_TEXTURE_2D, textureId); + + functions->glDisable(GL_STENCIL_TEST); + functions->glDisable(GL_DEPTH_TEST); + functions->glDisable(GL_SCISSOR_TEST); + functions->glDisable(GL_BLEND); GLfloat textureCoordinateArray[8]; textureCoordinateArray[0] = 0.0f; @@ -339,9 +341,9 @@ void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int he vertexCoordinateArray[6] = -1.0f; vertexCoordinateArray[7] = 1.0f; - glViewport(0, 0, width, height); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); + functions->glViewport(0, 0, width, height); + functions->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); + functions->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); { static const char *vertexShaderSource = @@ -362,72 +364,64 @@ void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int he " gl_FragColor = texture2D(texture, textureCoords); \n" "} \n"; - GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); - GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + GLuint vertexShader = functions->glCreateShader(GL_VERTEX_SHADER); + GLuint fragmentShader = functions->glCreateShader(GL_FRAGMENT_SHADER); if (vertexShader == 0 || fragmentShader == 0) { - GLenum error = glGetError(); - qWarning("SharedGraphicsCacheServer::setupShaderPrograms: Failed to create shaders. (GL error: %x)", + GLenum error = functions->glGetError(); + qWarning("QSGDistanceFieldGlyphCache::saveTexture: Failed to create shaders. (GL error: %x)", error); return; } - glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); - glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); - glCompileShader(vertexShader); + functions->glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); + functions->glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); + functions->glCompileShader(vertexShader); GLint len = 1; - glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len); + functions->glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len); char infoLog[2048]; - glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling vertex shader:\n %s", - infoLog); - } + functions->glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) + qWarning("Problems compiling vertex shader:\n %s", infoLog); - glCompileShader(fragmentShader); - glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems compiling fragent shader:\n %s", - infoLog); - } + functions->glCompileShader(fragmentShader); + functions->glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) + qWarning("Problems compiling fragment shader:\n %s", infoLog); - GLuint shaderProgram = glCreateProgram(); - glAttachShader(shaderProgram, vertexShader); - glAttachShader(shaderProgram, fragmentShader); + GLuint shaderProgram = functions->glCreateProgram(); + functions->glAttachShader(shaderProgram, vertexShader); + functions->glAttachShader(shaderProgram, fragmentShader); - glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray"); - glBindAttribLocation(shaderProgram, 1, "textureCoordArray"); + functions->glBindAttribLocation(shaderProgram, 0, "vertexCoordsArray"); + functions->glBindAttribLocation(shaderProgram, 1, "textureCoordArray"); - glLinkProgram(shaderProgram); - glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog); - if (qstrlen(infoLog) > 0) { - qWarning("SharedGraphicsCacheServer::setupShaderPrograms, problems linking shaders:\n %s", - infoLog); - } + functions->glLinkProgram(shaderProgram); + functions->glGetProgramInfoLog(shaderProgram, 2048, NULL, infoLog); + if (qstrlen(infoLog) > 0) + qWarning("Problems linking shaders:\n %s", infoLog); - glUseProgram(shaderProgram); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); + functions->glUseProgram(shaderProgram); + functions->glEnableVertexAttribArray(0); + functions->glEnableVertexAttribArray(1); - int textureUniformLocation = glGetUniformLocation(shaderProgram, "texture"); - glUniform1i(textureUniformLocation, 0); + int textureUniformLocation = functions->glGetUniformLocation(shaderProgram, "texture"); + functions->glUniform1i(textureUniformLocation, 0); } - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + functions->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); { - GLenum error = glGetError(); - if (error != GL_NO_ERROR) { - qWarning("SharedGraphicsCacheServer::readBackBuffer: glDrawArrays reported error 0x%x", - error); - } + GLenum error = functions->glGetError(); + if (error != GL_NO_ERROR) + qWarning("glDrawArrays reported error 0x%x", error); } uchar *data = new uchar[width * height * 4]; - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); + functions->glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); QImage image(data, width, height, QImage::Format_ARGB32); @@ -437,18 +431,16 @@ void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int he image.save(QString::fromLocal8Bit(fileName)); { - GLenum error = glGetError(); - if (error != GL_NO_ERROR) { - qWarning("SharedGraphicsCacheServer::readBackBuffer: glReadPixels reported error 0x%x", - error); - } + GLenum error = functions->glGetError(); + if (error != GL_NO_ERROR) + qWarning("glReadPixels reported error 0x%x", error); } - glDisableVertexAttribArray(0); - glDisableVertexAttribArray(1); + functions->glDisableVertexAttribArray(0); + functions->glDisableVertexAttribArray(1); - glDeleteFramebuffers(1, &fboId); - glDeleteTextures(1, &tmpTexture); + functions->glDeleteFramebuffers(1, &fboId); + functions->glDeleteTextures(1, &tmpTexture); delete[] data; } -- cgit v1.2.3 From 82c36e4ff05459a5affbb6f8fab75723baee20db Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 7 Nov 2014 12:54:16 +0100 Subject: QQuickWindow autotest: verify that onClosing can block close() Task-number: QTBUG-40093 Change-Id: I800259f45d95736172d500494e68042180178e93 Reviewed-by: Caroline Chao --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 043203c256..a25ed9bf9c 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -341,6 +341,7 @@ private slots: void testWindowVisibilityOrder(); void blockClosing(); + void blockCloseMethod(); void crashWhenHoverItemDeleted(); @@ -1739,6 +1740,25 @@ void tst_qquickwindow::blockClosing() QTRY_VERIFY(!window->isVisible()); } +void tst_qquickwindow::blockCloseMethod() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("ucantclosethis.qml")); + QQuickWindow *window = qobject_cast(component.create()); + QVERIFY(window); + window->show(); + QTest::qWaitForWindowExposed(window); + QVERIFY(window->isVisible()); + QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QVERIFY(window->isVisible()); + QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QVERIFY(window->isVisible()); + window->setProperty("canCloseThis", true); + QVERIFY(QMetaObject::invokeMethod(window, "close", Qt::DirectConnection)); + QTRY_VERIFY(!window->isVisible()); +} + void tst_qquickwindow::crashWhenHoverItemDeleted() { // QTBUG-32771 -- cgit v1.2.3 From cb023cbc2ab494eead21b721040a0a90db0f755c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 7 Nov 2014 11:33:14 +0100 Subject: QQuickWindow: let 'clearFocusObject' clear all the way to the root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous code was wrong, as it cleared focus from the active focus item directly. By doing so we would only clear focus inside the focus scope that surrounded the item, but leave the scope itself with active focus (which would then be the focus object). The intended result is rather to end up with the root as focus object. Change-Id: I455a8939f8bc6c48765119b995aa781aee6d1e70 Reviewed-by: Tor Arne Vestbø --- src/quick/items/qquickwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 619e539204..262e227b16 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -893,8 +893,10 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item, void QQuickWindowPrivate::clearFocusObject() { - if (activeFocusItem) - activeFocusItem->setFocus(false, Qt::OtherFocusReason); + if (activeFocusItem == contentItem) + return; + + clearFocusInScope(contentItem, QQuickItemPrivate::get(contentItem)->subFocusItem, Qt::OtherFocusReason); } void QQuickWindowPrivate::notifyFocusChangesRecur(QQuickItem **items, int remaining) -- cgit v1.2.3 From 868def84fe800aaba937159814388249ebbaf914 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Tue, 28 Oct 2014 15:40:49 +0100 Subject: qmlscene: Simplify context sharing logic. We can use the new application attribute for this now. Change-Id: Ia0a6d13d36316ec9becfb5d3251b8461ac73a2d0 Reviewed-by: Laszlo Agocs --- tools/qmlscene/main.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index bc339ae3e5..2a86b724f4 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -405,6 +405,9 @@ int main(int argc, char ** argv) } } + // QtWebEngine needs a shared context in order for the GPU thread to + // upload textures. + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, options.contextSharing); #ifdef QT_WIDGETS_LIB QApplication app(argc, argv); #else @@ -443,15 +446,6 @@ int main(int argc, char ** argv) displayFileDialog(&options); #endif - // QWebEngine needs a shared context in order for the GPU thread to - // upload textures. - QScopedPointer shareContext; - if (options.contextSharing) { - shareContext.reset(new QOpenGLContext); - shareContext->create(); - qt_gl_set_global_share_context(shareContext.data()); - } - int exitCode = 0; if (!options.file.isEmpty()) { -- cgit v1.2.3