1

次の Qt コードがありますnext()。私はコードを調べましたがQtConcurrent、なぜ失敗したのかは明らかではありません。

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);
}

アップデート:

の同じクラッシュQFuture::const_iterator


ノート:

私がGDBを信じることができれば、thisQVector::at ある0x0mapIterator.value().resultそれから私はすでに であると仮定しますnullptr、なぜ、私にはわかりません。

4

1 に答える 1

1

Qt4のドキュメントが間違っているようです。少なくともwaitForResult( int )、イテレータ内の呼び出しへの参照が見つかりませんでした。

ただし、直接使用することは機能しresultAtます。

だからあなたは交換するでしょう

for( auto it = future.begin(); it != future.end(); ++it ) {
    auto& result = *it;

for( int i = 0; i != count; ++i ) {
    auto result = future.resultAt( i );

クラッシュを防ぐために。

于 2013-06-28T07:48:50.667 に答える