Source

Target

Showing with 89 additions and 18 deletions
......@@ -38,6 +38,7 @@
#include <QtGui/QScreen>
#include <QtGui/QGuiApplication>
#include <QtGui/QOffscreenSurface>
#include <QtQuick/private/qsgcontext_p.h>
#include <QtQuick/private/qquickwindow_p.h>
......@@ -210,15 +211,29 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
hide(window);
QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
if (m_gl)
m_gl->makeCurrent(window);
bool current = false;
QScopedPointer<QOffscreenSurface> offscreenSurface;
if (m_gl) {
QSurface *surface = window;
// There may be no platform window if the window got closed.
if (!window->handle()) {
offscreenSurface.reset(new QOffscreenSurface);
offscreenSurface->setFormat(m_gl->format());
offscreenSurface->create();
surface = offscreenSurface.data();
}
current = m_gl->makeCurrent(surface);
}
if (Q_UNLIKELY(!current))
qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";
d->cleanupNodesOnShutdown();
if (m_windows.size() == 0) {
d->context->invalidate();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
delete m_gl;
m_gl = 0;
} else if (m_gl) {
} else if (m_gl && current) {
m_gl->doneCurrent();
}
}
......
!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
# DEFINES += QSG_SEPARATE_INDEX_BUFFER
# DEFINES += QSG_DISTANCEFIELD_CACHE_DEBUG
# Core API
HEADERS += \
......
......@@ -36,6 +36,7 @@
#include <QHostAddress>
#include <QDebug>
#include <QThread>
#include <QModelIndex>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
......@@ -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<CustomTypes>("Backend", 1, 0, "CustomTypes");
qml << "import Backend 1.0\n"
"CustomTypes {}"
;
for (int i=0; i<qml.count(); i++) {
QQmlComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
......@@ -620,7 +638,7 @@ void tst_QQmlEngineDebugService::queryRootContexts()
// root context query sends only root object data - it doesn't fill in
// the children or property info
QCOMPARE(context.objects.count(), 0);
QCOMPARE(context.contexts.count(), 5);
QCOMPARE(context.contexts.count(), 6);
QVERIFY(context.contexts[0].debugId >= 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()
{
......
......@@ -383,8 +383,6 @@ void tst_QQuickAccessible::checkableTest()
QScopedPointer<QQuickView> 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<QQuickView> window(new QQuickView());
window->setSource(testFileUrl("ignored.qml"));
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickItem *contentItem = window->contentItem();
QVERIFY(contentItem);
......
......@@ -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
}
}
}
......@@ -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<QQuickWindow *>(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
......@@ -1952,6 +1972,7 @@ void tst_qquickwindow::attachedProperty()
view.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.rootObject()->property("windowActive").toBool());
QCOMPARE(view.rootObject()->property("contentItem").value<QQuickItem*>(), view.contentItem());
QQuickWindow *innerWindow = view.rootObject()->findChild<QQuickWindow*>("extraWindow");
QVERIFY(innerWindow);
......@@ -1961,6 +1982,7 @@ void tst_qquickwindow::attachedProperty()
QQuickText *text = view.rootObject()->findChild<QQuickText*>("extraWindowText");
QVERIFY(text);
QCOMPARE(text->text(), QLatin1String("active\nvisibility: 2"));
QCOMPARE(text->property("contentItem").value<QQuickItem*>(), innerWindow->contentItem());
}
class RenderJob : public QRunnable
......
......@@ -494,6 +494,7 @@ int main(int argc, char *argv[])
foreach (const QString &path, files) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression urlRe("[[:word:]]+://.*");
if (urlRe.match(path).hasMatch()) { //Treat as a URL
QUrl url = QUrl::fromUserInput(path);
......@@ -503,7 +504,9 @@ int main(int argc, char *argv[])
? QDir::toNativeSeparators(url.toLocalFile())
: url.toString()));
e.load(url);
} else { //Local file path
} else
#endif
{ //Local file path
if (verboseMode)
printf("qml: loading %s\n", qPrintable(QDir::toNativeSeparators(path)));
......
......@@ -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<QOpenGLContext> 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()) {
......