diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp --- a/generators/epub/converter.cpp +++ b/generators/epub/converter.cpp @@ -307,10 +307,10 @@ qApp->setPalette(orig); // HACK END - QTextCursor csr(mTextDocument); // a temporary cursor - csr.movePosition(QTextCursor::Start); + QTextCursor csr(before); // a temporary cursor pointing at the begin of the last inserted block int index = 0; - while( !(csr = mTextDocument->find(QStringLiteral(""),csr)).isNull() ) { + + while( !movieAnnots.isEmpty() && !(csr = mTextDocument->find(QStringLiteral(""),csr)).isNull() ) { const int posStart = csr.position(); const QPoint startPoint = calculateXYPosition(mTextDocument, posStart); QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-movie.png"))); @@ -323,10 +323,10 @@ csr.movePosition(QTextCursor::NextWord); } - csr.movePosition(QTextCursor::Start); + csr = QTextCursor(before); index = 0; const QString keyToSearch(QStringLiteral("")); - while( !(csr = mTextDocument->find(keyToSearch, csr)).isNull() ) { + while( !soundActions.isEmpty() && !(csr = mTextDocument->find(keyToSearch, csr)).isNull() ) { const int posStart = csr.position() - keyToSearch.size(); const QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-sound-icon.png"))); csr.insertImage(img);