QML标签在OpenGL核心配置文件下会导致应用程序崩溃。

3

我从一个新的QtQuick2项目开始,使用Ubuntu 12.04和Mac OSX。我已经在Qt 5.3.1和5.3.2上尝试过了。

我使用这段代码创建了一个设置为OpenGL 4.1核心配置文件的QQuickView。

QApplication app(argc, argv);

QQuickView * m_pMainView = new QQuickView;

QSurfaceFormat f;
f.setProfile(QSurfaceFormat::CoreProfile);
f.setVersion(4, 1);
m_pMainView->setFormat(f);

m_pMainView->setSource(QUrl("qrc:///main.qml"));

m_pMainView->show();

return app.exec();

我的QML很简单。

import QtQuick 2.3
import QtQuick.Controls 1.2

Rectangle {
    visible: true

    height: 800
    width: 600

    Label {
        text: "Test"
    }
}

运行此代码会立即导致应用程序崩溃。将QML中的Label控件切换为Text控件,不会崩溃,正常运行。将QSurfaceFormat切换为适用的兼容性配置文件(Ubuntu上的3.3 / Mac上的2.1),不会崩溃,正常运行。
我在更改OpenGL版本时是否做错了什么,还是Qt 5.3在核心配置文件方面不稳定?
如果有用的话,这里是来自Mac的堆栈跟踪:
    Thread 6 Crashed:: QSGRenderThread
0   QtGui                           0x0000000101cd41a7 QOpenGLContextPrivate::maxTextureSize() + 343
1   QtGui                           0x0000000101f33907 QOpenGLTextureGlyphCache::maxTextureHeight() const + 39
2   QtGui                           0x0000000101ec4137 QTextureGlyphCache::populate(QFontEngine*, int, unsigned int const*, QFixedPoint const*) + 1687
3   QtQuick                         0x0000000100d488f0 QSGTextMaskMaterial::populate(QPointF const&, QVector<unsigned int> const&, QVector<QPointF> const&, QSGGeometry*, QRectF*, QPointF*, QMargins const&) + 432
4   QtQuick                         0x0000000100d473fd QSGDefaultGlyphNode::update() + 797
5   QtQuick                         0x0000000100dc7632 QQuickTextNode::addGlyphs(QPointF const&, QGlyphRun const&, QColor const&, QQuickText::TextStyle, QColor const&, QSGNode*) + 482
6   QtQuick                         0x0000000100dcbc61 QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode*, QQuickText::TextStyle, QColor const&) + 2049
7   QtQuick                         0x0000000100dc7fbd QQuickTextNode::addTextLayout(QPointF const&, QTextLayout*, QColor const&, QQuickText::TextStyle, QColor const&, QColor const&, QColor const&, QColor const&, int, int, int, int) + 557
8   QtQuick                         0x0000000100dc5368 QQuickText::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) + 1000
9   QtQuick                         0x0000000100d88995 QQuickWindowPrivate::updateDirtyNode(QQuickItem*) + 3317
10  QtQuick                         0x0000000100d7fdb2 QQuickWindowPrivate::syncSceneGraph() + 306
11  QtQuick                         0x0000000100d5d388 QSGRenderThread::sync() + 120
12  QtQuick                         0x0000000100d5d475 QSGRenderThread::syncAndRender() + 117
13  QtQuick                         0x0000000100d5d968 QSGRenderThread::run() + 200
14  QtCore                          0x00000001016923f2 QThreadPrivate::start(void*) + 338
15  libsystem_pthread.dylib         0x00007fff94d23899 _pthread_body + 138
16  libsystem_pthread.dylib         0x00007fff94d2372a _pthread_start + 137
17  libsystem_pthread.dylib         0x00007fff94d27fc9 thread_start + 13

同样地,在这个相同的 main.cpp / main.qml 组合下,对一个 png 文件应用不透明度掩码会产生一系列片段着色器错误和无渲染,而切换回兼容性配置文件则可以正常工作。 - Evan
1
有没有可能你可以编辑你的问题并包含这个跟踪信息,而不是把它作为难以阅读的一堆注释粘贴上去? - Andon M. Coleman
你的图形硬件是否支持OGLv4.1? - cmannett85
是的,我的两台机器上的硬件都支持4.1。值得注意的是,我在3.3 Core上得到了完全相同的结果。我已经更新了问题并附上了堆栈跟踪。 - Evan
另外,如果我将一个自定义的OpenGL小部件添加到工作版本(具有文本而不是标签的版本)中,并打印我的OpenGL上下文版本,则会输出预期/请求的版本。 - Evan
1个回答

4

尽管Qt团队的一些成员已经表示Qt版本5.2及以上与核心配置文件兼容,但事实是Qt控件直到5.4版本才能正常工作。这里是问题所在:

https://bugreports.qt.io/browse/QTBUG-38817


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接