From 74a20b77a67ec4d5a8be0f59302075d34151dc05 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 12:46:04 +0200 Subject: Fix memory leak in QClipboard::setMimeData() The setMimeData() function is documented to take ownership of the object passed in, but in the case where the platform plugin did not support the requested mode, we would simply return without deleting the object nor telling the application, so it would cause a potential memory leak. We need to honor the contract, even when we fail to set the mime data. Test was updated to avoid verifying the leak in cases where the platform does not support all modes. [ChangeLog][QtGui][Clipboard] Fixed a memory leak in setMimeData() when the platform plugin did not support the requested mode. Task-number: QTBUG-41852 Change-Id: I2112da1613199fe1b56724e7ccf097b9e912c117 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qclipboard.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index ec9a8fdcf0..5be9f19b3e 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -463,9 +463,14 @@ const QMimeData* QClipboard::mimeData(Mode mode) const void QClipboard::setMimeData(QMimeData* src, Mode mode) { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - if (!clipboard->supportsMode(mode)) return; - - clipboard->setMimeData(src,mode); + if (!clipboard->supportsMode(mode)) { + if (src != 0) { + qWarning("Data set on unsupported clipboard mode. QMimeData object will be deleted."); + src->deleteLater(); + } + } else { + clipboard->setMimeData(src,mode); + } } /*! -- cgit v1.2.3 From 8304c8087d269b5b48621cc18d3ebe2bd369ebf4 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 9 Jan 2014 15:29:28 +0100 Subject: Doc: Update description of QKeyEvent class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the description on how to use the QKeyEvent pointer passed to key event handlers, and remove an outdated note about multimedia key events. Change-Id: I67a3f0054e28b84d5a0e367c02a329f4670221c7 Task-number: QTBUG-35155 Reviewed-by: Topi Reiniƶ --- src/gui/kernel/qevent.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f99f28d6e0..a8539e8013 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -897,12 +897,11 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, when keys are pressed or released. A key event contains a special accept flag that indicates whether - the receiver will handle the key event. You should call ignore() - if the key press or release event is not handled by your widget. - A key event is propagated up the parent widget chain until a - widget accepts it with accept() or an event filter consumes it. - Key events for multimedia keys are ignored by default. You should - call accept() if your widget handles those events. + the receiver will handle the key event. This flag is set by default, + so there is no need to call accept() when acting on a key event. + Calling ignore() on a key event will propagate it to the parent widget. + The event is propagated up the parent widget chain until a widget + accepts it or an event filter consumes it. The QWidget::setEnable() function can be used to enable or disable mouse and keyboard events for a widget. -- cgit v1.2.3 From d92a9ca2d33ae737b4b4362561209324ade3c95b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 13 Oct 2014 11:57:13 +0200 Subject: Update QOffscreenSurface docs regarding threads Change-Id: Ic2e3230835aa7fc1b1c3ac0530a65cd478e1ec5f Reviewed-by: Gunnar Sletta --- src/gui/kernel/qoffscreensurface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index 56c4fbbf8b..5cf77de5d8 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -64,6 +64,12 @@ QT_BEGIN_NAMESPACE typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally. + \note Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms, + cross-platform applications must ensure that create() is only called on the main (GUI) + thread. The QOffscreenSurface is then safe to be used with + \l{QOpenGLContext::makeCurrent()}{makeCurrent()} on other threads, but the + initialization and destruction must always happen on the main (GUI) thread. + \note In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context's or the window's actual format, that is, the QSurfaceFormat returned from @@ -152,6 +158,8 @@ QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const Call destroy() to free the platform resources if necessary. + \note Some platforms require this function to be called on the main (GUI) thread. + \sa destroy() */ void QOffscreenSurface::create() -- cgit v1.2.3 From 5d9dcac0f2dc8da1a1ac79dbdd309654d6deabac Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 30 Sep 2014 10:42:43 +0200 Subject: qplatformmenu: remove unused and deprecated function Now that all platforms use the popup function that takes a target rect, lets remove the deprecated one. This is sort of important, since QtQuick controls now uses the new version. So if a (new) platform ends up only implementing the old version, that can end up not working correctly. Change-Id: I34814b3de5ea4954cf21b161e8a834e39e5534c8 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qplatformmenu.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index c832de0be6..0093ef1538 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -108,11 +108,6 @@ public: virtual void setFont(const QFont &font) { Q_UNUSED(font); } virtual void setMenuType(MenuType type) { Q_UNUSED(type); } - virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) - { - showPopup(parentWindow, QRect(pos, QSize()), item); - } - virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); -- cgit v1.2.3 From c231694949cfcf43952ea23539c3f10f670b5fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 17 Sep 2014 14:49:08 +0200 Subject: Fix QOpenGLWindow tests when devicePixelRatio != 1 Change-Id: I83d71de8b9d735cd649a6c514e41a9ff23625005 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglwindow.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index 2b6692c461..158fb248dc 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -211,8 +211,11 @@ public: context->makeCurrent(q); } + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); + const QSize deviceSize(deviceWidth, deviceHeight); if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (!fbo || fbo->size() != q->size() * q->devicePixelRatio()) { + if (!fbo || fbo->size() != deviceSize) { QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); if (q->requestedFormat().samples() > 0) { @@ -221,15 +224,13 @@ public: else qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling"); } - fbo.reset(new QOpenGLFramebufferObject(q->size() * q->devicePixelRatio(), fboFormat)); + fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat)); markWindowAsDirty(); } } else { markWindowAsDirty(); } - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); paintDevice->setSize(QSize(deviceWidth, deviceHeight)); paintDevice->setDevicePixelRatio(q->devicePixelRatio()); context->functions()->glViewport(0, 0, deviceWidth, deviceHeight); @@ -252,11 +253,13 @@ public: context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) { + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); QOpenGLExtensions extensions(context.data()); extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle()); extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject()); - extensions.glBlitFramebuffer(0, 0, q->width(), q->height(), - 0, 0, q->width(), q->height(), + extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight, + 0, 0, deviceWidth, deviceHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) { @@ -591,7 +594,7 @@ int QOpenGLWindow::metric(PaintDeviceMetric metric) const break; case PdmDevicePixelRatio: if (d->paintDevice) - return d->paintDevice->devicePixelRatio(); + return devicePixelRatio(); break; default: break; -- cgit v1.2.3 From c762c8accc1c1b89253fbb3b5687459a8605449c Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 10 Sep 2014 18:27:07 +0200 Subject: Remove QOpenGLContextPrivate::globalShareContext This has previously been replaced with qt_gl_global_share_context and all using code has been ported to the new name at this point. Change-Id: I13832f583456891dd057a7b414f45ec3e83f5698 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext.cpp | 10 ---------- src/gui/kernel/qopenglcontext_p.h | 3 --- 2 files changed, 13 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 8b2378788f..1a8a534e11 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -350,16 +350,6 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context return previous; } -void QOpenGLContextPrivate::setGlobalShareContext(QOpenGLContext *context) -{ - qt_gl_set_global_share_context(context); -} - -QOpenGLContext *QOpenGLContextPrivate::globalShareContext() -{ - return qt_gl_global_share_context(); -} - int QOpenGLContextPrivate::maxTextureSize() { if (max_texture_size != -1) diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 7c45737d0a..d5a3126176 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -241,9 +241,6 @@ public: static QOpenGLContext *setCurrentContext(QOpenGLContext *context); - static void setGlobalShareContext(QOpenGLContext *context); - static QOpenGLContext *globalShareContext(); - int maxTextureSize(); static QOpenGLContextPrivate *get(QOpenGLContext *context) -- cgit v1.2.3 From 929d6d6b9b31967f13bcd51a421678edcb06d184 Mon Sep 17 00:00:00 2001 From: Josh Faust Date: Mon, 9 Sep 2013 21:33:25 -0600 Subject: Fix ShortcutOverride for QtQuick on OSX tryShortcutOverride on OSX gets called via QWindowSystemInterface::tryHandleShortcutEvent. This change fixes that to use the QWindow's focus object. Task-number: QTBUG-32928 Change-Id: I51beb774e1fb91e0d8e2c12d087176d917357311 Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qwindowsysteminterface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d03a3f7be8..bd95a8614f 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -201,9 +201,13 @@ bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp, #ifndef QT_NO_SHORTCUT QGuiApplicationPrivate::modifier_buttons = mods; + QObject *focus = w->focusObject(); + if (!focus) + focus = w; + QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count); qevent.setTimestamp(timestamp); - return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); + return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent); #else Q_UNUSED(w) Q_UNUSED(timestamp) @@ -231,9 +235,13 @@ bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong ti #ifndef QT_NO_SHORTCUT QGuiApplicationPrivate::modifier_buttons = mods; + QObject *focus = w->focusObject(); + if (!focus) + focus = w; + QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count); qevent.setTimestamp(timestamp); - return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent); + return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent); #else Q_UNUSED(w) Q_UNUSED(timestamp) -- cgit v1.2.3