我有一个
QQuickItem
它为文本编辑器显示文本光标,首先我只有一个光标(
QSGGeometry
QOpacityNode
. 当我增加光标的数量时,新的光标被放置在opacity节点中,但是调用
QSGNode.appendChildNode()
将军
分段故障
QSGNode * CursorsArea::updatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *){
if (node == nullptr) {
node = new QSGOpacityNode;
}
if (!alpha.update()) {
if (alpha.currentAlpha >= 1.0) {
alpha.setCurrentAlpha(0.0);
}
else {
alpha.setCurrentAlpha(1.0);
}
}
if (editor == nullptr) {
return node;
}
if (node->childCount() != editor->selectionsCount()) {
if (node->childCount() < editor->selectionsCount()) {
for (int i = node->childCount(); i < editor->selectionsCount();
i++) {
auto * geometryNode = new QSGGeometryNode;
auto * geometry =
new QSGGeometry{QSGGeometry::defaultAttributes_Point2D(), 2};
geometry->setLineWidth(m_cursorW);
geometry->setDrawingMode(QSGGeometry::DrawLines);
geometryNode->setGeometry(geometry);
geometryNode->setFlag(QSGNode::OwnsGeometry);
node->appendChildNode(geometryNode); // Segmentation fault here
}
}
else {
while (editor->selectionsCount() < node->childCount()) {
node->removeChildNode(node->firstChild());
}
}
}
}
堆栈跟踪:
qsgbatchrender::节点*)0x7ffff1248245 2
QFlags)0x7ffff124b592 3个
QFlags公司)
0x7ffff1235b18 4 qsnode::markDirty(QFlags)
0x7ffff1235b99 5 icL::编辑器::光标区域::更新点输入节点
光标区域.cpp 91 0x7fffd1124939 6
0x7ffff12d7320 7 QQuickWindowPrivate::updateDirtyNodes()
0x7ffff12d7794 8 QQuickWindowPrivate::syncSceneGraph()
0x7ffff12665b3 10 QQuickWindow::事件(QEvent*)
0x7ffff12e3b06 11 QApplicationPrivate::通知帮助程序(QObject*,
12 QApplication::通知(QObject*,QEvent*)
0x7ffff7ac86e113 QCoreApplication::通知内部2(QObject*,
QEvent*)
0x7ffff020ec39 14 QWindowPrivate::deliverUpdateRequest()
0x7ffff0c65d8b 16 QQuickWindow::事件(QEvent*)
QEvent*)0x7ffff7ac0e14
18 QApplication::通知(QObject*,QEvent*)
QEvent*)
0x7ffff020ec39 20个QTimerInfoList::激活定时器()
0x7ffff0261c5a 22 g_主上下文调度
0x7fffef92d3cf 23英寸??
0x7fffef92efce 25个
QEventDispatcherGlib::处理事件(QFlags)
0x7ffff0261fc9 26??
QEventLoop::exec(QFlags)
0x7ffff020d8cc 28 QCoreApplication::exec()
0x7FF0215BC6 29主
主.cpp
我怎么能修好它?