How do I use QtConcurrent::map()
I have tried to implement QtConcurrent, but it crashes
stating the below error
"Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8cb0f866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff87aee35c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff89f2fb1a abort + 125
3 org.qt-project.QtCore 0x000000010c1a2159 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 9
4 org.qt-project.QtCore 0x000000010c1a3611 QMessageLogger::fatal(char const*, ...) const + 161
5 org.qt-project.QtCore 0x000000010c19e815 qt_assert_x(char const*, char const*, char const*, int) + 85
6 com.yourcompany.learnOn 0x000000010b2cd880 QList<QFileInfo>:perator[](int) + 96 (qlist.h:486)
7 com.yourcompany.learnOn 0x000000010b2cbf8a loadbook::decryptLoop(int, int) + 138 (loadbook.cpp:122)
ASSERT failure in QList<T>:perator[]: "index out of range", file /Applications/QT/5.4/clang_64/lib/QtCore.framework/Headers/qlist.h, line 486
The program has unexpectedly finished.
The code is as below
totalXHtmlPages = 173
int index=0;
while( index <totalXHtmlPages)
{
if(stopThread) return;
QFuture<QStringList> test = QtConcurrent::run(this,&loadbook::decryptLoop,index,index+13);
PgContents.append(test.result());
index = index + 13;
}
QStringList loadbook
::decryptLoop(int startIndex,
int endIndex
) {
for(int index = startIndex; index < endIndex; index++)
{
if(stopThread) break;
decryptContent.append(decrypt->decryptFile(FileInfoList[index].absoluteFilePath(), 'A'));
qDebug()<<"FileInfoList["<<index<<"] -> "<<FileInfoList[index].absoluteFilePath();
}
return decryptContent;
}
totalXHtmlPages = 173
int index=0;
while( index <totalXHtmlPages)
{
if(stopThread) return;
QFuture<QStringList> test = QtConcurrent::run(this,&loadbook::decryptLoop,index,index+13);
PgContents.append(test.result());
index = index + 13;
}
QStringList loadbook::decryptLoop(int startIndex, int endIndex)
{
QStringList decryptContent;
for(int index = startIndex; index < endIndex; index++)
{
if(stopThread) break;
decryptContent.append(decrypt->decryptFile(FileInfoList[index].absoluteFilePath(), 'A'));
qDebug()<<"FileInfoList["<<index<<"] -> "<<FileInfoList[index].absoluteFilePath();
}
return decryptContent;
}
To copy to clipboard, switch view to plain text mode
Here I dont find multiple thread which I intended to create.
how can I make this 173 files to be decrypted as fast as possible using threads
Bookmarks