Q_ASSERT(unindexedItems.isEmpty())失败

时间:2016-11-18 07:32:46

标签: c++ qt open-source

我定义了一个函数:

void RealTimeMonitor::simulateMove(const QVector<QPointF> &path)
{
//pForklifts_[0] is a QGraphicsItem*,I want to move it along the path.
//omit some irrespective code just...
    pForklifts_[0]->setPos(x, y);
}

如果我直接称之为乐趣,一切都顺利。但是,当我在std :: thread中调用乐趣时:

std::thread threadSimulateMove(&RealTimeMonitor::simulateMove, this, path);
threadSimulateMove.detach();

我会得到错误作为标题显示。我尝试跟踪qt源,但没有太多时间,也不理解 unindexedItems 的角色.-- unindexedItems 类QGraphicsSceneBspTreeIndexPrivate 中的成员变量,在 qgraphicsscenebsptreeindex_p.h 中定义。

1 个答案:

答案 0 :(得分:0)

那是因为另一个线程无法操作GUI。另一个问题是var var1=[{key:"key1",value1:"value11"},{key:"key2",value1:"value12"}],var2=[{key:"key1",value2:"value21"},{key:"key2",value2:"value22"}]; // O(N+M) time, O(N) space function mergeLinear(arr1, arr2) { // create a map of key->obj for every object in arr2 var map = arr2.reduce(function(map, curr) { map[curr.key] = curr; return map; }, Object.create(null)); var result = []; arr1.forEach(function(obj1) { // check almost instantly if a matching object exists var obj2 = map[obj1.key]; // <-- Constant time lookup // if we found a match, we can merge these two objects if (obj2) { result.push(Object.assign({}, obj1, obj2)); } }); return result; } console.log(mergeLinear(var1, var2));无法使用QVector - 实际上很难使用。我在线程中启动一个生成connect的新线程,如:

QVector<QPointF>

然后,反复快速地向gui线程发出信号(例如std::thread threadSimulateMove(&RealTimeMonitor::simulateMove, this, forkliftId, pathLoad,pathUnload); threadSimulateMove.detach(); )。