У меня есть следующий код Qt, который segfaults находится в next()
. Я заглянул в код QtConcurrent
, и для меня это не очевидно, почему он терпит неудачу.QFutureIterator :: next segfaults
namespace {
std::tuple<QString, std::exception_ptr> test(const int& data) {
return std::make_tuple(QString(), std::exception_ptr());
}
}
void
start() {
QVector<int> downloadList;
downloadList.push_back(1);
downloadList.push_back(2);
auto future = QtConcurrent::mapped(downloadList, test);
QFutureIterator<std::tuple<QString, std::exception_ptr>> it(future);
while(it.hasNext()) {
auto& tuple = it.next();
}
}
Точка он не является:
const T *pointer() const
{
if (mapIterator.value().isVector())
-> return &(reinterpret_cast<const QVector<T> *>(mapIterator.value().result)->at(m_vectorIndex));
else
return reinterpret_cast<const T *>(mapIterator.value().result);
}
Update:
То же крах для QFuture::const_iterator
.
Примечание:
Если я могу поверить, что GDB, this
в QVector::at
является 0x0
. Тогда я предполагаю, что mapIterator.value().result
уже есть nullptr
, почему, я понятия не имею.
Просто спрашивайте ... вы уверены, что можете использовать итератор на QFuture до завершения QFuture? – peppe
Согласно [doc] (http://harmattan-dev.nokia.com/docs/library/html/qt4/qfutureiterator.html#details), да. – abergmeier