aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets/qquickwidget.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
commit1fb1c6c4f8769250dffa375e3941738eb1fcc885 (patch)
tree4f4c4afae97b54a793a0589f8ca53b7c919de728 /src/quickwidgets/qquickwidget.cpp
parentd0ce320646b7f852a24f6e0a9e9621ddcedef554 (diff)
parent9c1c471e54bb12e8740b76d1c048f2f916a6ab59 (diff)
Merge remote-tracking branch 'origin/dev' into wip/pointerhandler
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r--src/quickwidgets/qquickwidget.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 4ed41a0c6c..a2ea0f7af2 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -76,10 +76,6 @@
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(opengl)
-extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
-#endif
-
class QQuickWidgetRenderControl : public QQuickRenderControl
{
public:
@@ -157,6 +153,16 @@ void QQuickWidgetPrivate::invalidateRenderControl()
#endif
renderControl->invalidate();
+
+ // Many things can happen inside the above invalidate() call, including a
+ // change of current context. Restore if needed since some code will rely
+ // on the fact that this function makes and leaves the context current.
+#if QT_CONFIG(opengl)
+ if (!useSoftwareRenderer && context) {
+ if (QOpenGLContext::currentContext() != context)
+ context->makeCurrent(offscreenSurface);
+ }
+#endif
}
void QQuickWidgetPrivate::handleWindowChange()
@@ -353,10 +359,9 @@ QImage QQuickWidgetPrivate::grabFramebuffer()
return renderControl->grab();
}
-QObject *QQuickWidgetPrivate::focusObject()
-{
- return offscreenWindow ? offscreenWindow->focusObject() : 0;
-}
+// Intentionally not overriding the QQuickWindow's focusObject.
+// Key events should go to our key event handlers, and then to the
+// QQuickWindow, not any in-scene item.
/*!
\module QtQuickWidgets
@@ -1140,7 +1145,7 @@ QSize QQuickWidget::initialSize() const
/*!
Returns the view's root \l {QQuickItem} {item}. Can be null
- when setContents/setSource has not been called, if they were called with
+ when setSource() has not been called, if it was called with
broken QtQuick code or while the QtQuick contents are being created.
*/
QQuickItem *QQuickWidget::rootObject() const