2016-03-22 7 views
3

この関数は、(ほぼ)同じフラグメントによりQStringのを分割する必要があり、同じ結果を返します:のQString ::半ば()常に

QStringList splitCell(const QString& cell) const 
{ 
    QStringList result; 

    const int currentSize = cell.size(); 
    const int fragmentCount = currentSize/c_maxCellSize + (currentSize % c_maxCellSize ? 1 : 0); // c_maxCellSize = 32758 
    const int fragmentSize = currentSize/fragmentCount + (currentSize % fragmentCount ? 1 : 0); 

    for (int fragment = 0; fragment < fragmentCount; ++fragment) 
    { 
     QString currentFragment = cell.mid(fragmentSize * fragment, fragmentSize); 
     result << currentFragment; 
    } 

    return result; 
} 

しかしfragmentCount> 1その後currentFragmentは、常にすべての反復で同じである場合。どうしましたか? P.P.セルストリングが大きい(最大100Kシンボル)

+0

問題を再現する最小限の自己完結型の例を提供できますか? –

+0

はうまく動作します。それにもかかわらず、あなたの 'fragmentSize'は常に' c_maxCellSize'ですか? –

+0

@SebastianLangeいいえ、cell.size() LibertyPaul

答えて

0

これはコンパイラの問題(MS VS2008-恐竜版)のようです。 いくつかの再構築の後、正常に動作します。

関連する問題